This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sxw's profile picture

EnderCC: Easy HTTP networking

Started by Sxw, 13 July 2014 - 09:15 PM
Sxw #1
Posted 13 July 2014 - 11:15 PM
EnderCC is a HTTP framework. It's easy to use and you don't have to setup your own server!

Download:
pastebin get V91n5SXC ender

Usage in a lua prompt:
On one computer:

os.loadAPI("ender")
ender.connect("testchannel")
-- Send message on other computer
ender.receive("testchannel")
On the other:

os.loadAPI("ender")
ender.send("testchannel", "Hello!"))
ender.getName("testchannel") -- The computers name that appears to other clients
Edited on 17 March 2015 - 04:15 PM
Kizz #2
Posted 14 July 2014 - 07:09 PM
Isn't this basically the modem API?
flaghacker #3
Posted 14 July 2014 - 09:51 PM
It's meant to be like the modem API, but it is via http, vis an external server. It has infinite range and works between dimensions and even servers. (at least that's what I think)
Edited on 14 July 2014 - 07:53 PM
Kizz #4
Posted 15 July 2014 - 02:53 PM
Ow nice! Yea, I kinda missed the HTTP part. Lack of sleep is getting to me!
Sxw #5
Posted 16 July 2014 - 01:22 AM
Yes, it's designed for cross world and server communication.
biggest yikes #6
Posted 18 July 2014 - 01:31 AM
So is this your way of making that email between servers you mentioned on irresponsiblecraft?
bigbrainiac10 #7
Posted 23 July 2014 - 08:56 AM
Whenever I try to use this API, I always get an error on line 113.

I'm trying to use the examples provided.
Sxw #8
Posted 29 July 2014 - 12:10 AM
That's odd. What is the error? Line 113 is just an http.get. Do you have HTTP enabled?
bigbrainiac10 #9
Posted 29 July 2014 - 03:37 AM
I have HTTP enabled. I believe the error I receive is a "index nil value" error
Sxw #10
Posted 08 August 2014 - 05:01 PM
Are you sure you have http on? Try typing http.get("http://fluidnode.com/ping") into a lua console.
If that works, are you using the latest version?
ardera #11
Posted 31 August 2014 - 04:48 PM
It seems you need to pass an argument to ender.receive, otherwise ender.connect (which is called by ender.receive) searches for nil in the connected channels list, which isn't there, so it calls rawStart to connect to 'nil'. rawStart calls http.get with a string concatenated with the channel which is nil, and baam, "attempt to concatenate string and nil"

Then, line 179,

chans[channel] --# needs to be:
chans[channel][1]

Sending doesn't work serverside, if I try to send "hey" in a browser, it errors:

TypeError: Object #<Object> has no method 'forEach'
   at /var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/app/views/EnderCC.js:32:12
   at Layer.handle [as handle_request] (/var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/layer.js:76:5)
   at next (/var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/route.js:100:13)
   at Route.dispatch (/var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/route.js:81:3)
   at Layer.handle [as handle_request] (/var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/layer.js:76:5)
   at /var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/index.js:227:24
   at Function.proto.process_params (/var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/index.js:305:12)
   at /var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/index.js:221:12
   at Function.match_layer (/var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/index.js:288:3)
   at next (/var/lib/openshift/53a07cf1500446c6e3000183/app-root/runtime/repo/node_modules/express/lib/router/index.js:182:10)

I love the idea, and I'd love to see this in action :)/>
Edited on 31 August 2014 - 02:51 PM
Hydrotronics #12
Posted 17 August 2016 - 05:37 PM
How do I use the API to send strings? I'm currently trying to make a cross server chat for my OS (you will be credited) and when I tried pasting the message on the screen of the receiving end, it came up with "truetest" and then a bunch of characters and numbers. It looks as though it's been encrypted :P/> how do I convert it back?