301 posts
Location
Whenever, Wherever!
Posted 04 October 2013 - 06:54 PM
Zombienet is a framework to let you communicate over http, cross server.
Usage:
Spoiler
1. Download (pastebin get xqdNSNwY zn) and os.loadAPI("zn")
2. Call zn.start([channel])
Channel is optional, and if omitted, will generate a random one
Returns: true, channel, sid (for advanced uses)
3. zn.poll()
Returns:
No message: false, "nomsg"
Message: true, "message here"
4. zn.send(msg)
Sends a message to the channel
5. zn.daemon (Run in coroutine)
Runs in background and queues zn_msg(msg) whenever there is a new message.Notes:
Spoiler
This runs on my server, so please don't abuse it. If there is enough interest, I might publish instructions for running your own.
For science!Download:
pastebin.com/xqdNSNwYpastebin get xqdNSNwY zn
Edited on 15 December 2013 - 03:26 PM
2217 posts
Location
3232235883
Posted 04 October 2013 - 07:07 PM
i have to say this, but Zombienet was actually developed before httpnet
so no flamewars about stealing .-.
892 posts
Location
Where you'd least expect it.
Posted 04 October 2013 - 07:33 PM
Telling programmers "don't mess with my server" is equivalent to telling a thief "don't touch my stuff".
375 posts
Location
USA
Posted 04 October 2013 - 07:58 PM
Telling programmers "don't mess with my server" is equivalent to telling a thief "don't touch my stuff".
Yes, you can always use the "For science!" excuse.
1114 posts
Location
UK
Posted 05 October 2013 - 12:18 AM
I like the idea of queuing an event when a message is received.
67 posts
Posted 20 October 2013 - 08:38 AM
I tried doing something like this 6 months ago, but I couldn't get it to work with 000webhost because it was sending too many messages to the site, and 000webhost blocks that .-.
2217 posts
Location
3232235883
Posted 20 October 2013 - 04:02 PM
I tried doing something like this 6 months ago, but I couldn't get it to work with 000webhost because it was sending too many messages to the site, and 000webhost blocks that .-.
its verry hard to do in php
well properly that is, the proper way is to only serve the request only when its needed (long polling)
the way php was designed makes this hard to do without being slow, taking up unnecicary threads, etc
this can be done in node.js pretty easialy though, but i prefer luvit because it is lua
though i would like plugins have access to libraries like sqlite, thats why i use normal lua
163 posts
Location
Pennsylvania
Posted 02 December 2013 - 07:09 PM
This looks great! I'd definitely like to have it running on my server! Any chance you could post those instructions?
301 posts
Location
Whenever, Wherever!
Posted 14 December 2013 - 12:18 PM
Well, the current code is kinda messy, but you could make your own server. The protocol is very simple. But the main point of this is cross server communication, so it might be better to just use my server. For reference:
Spoiler
zn.fluidnode.com/obtain
Grab session id for channel or random channel.
zn.fluidnode.com/send
Sends a message to session id's channel.
zn.fluidnode.com/poll
Returns a message from session id's message queue
71 posts
Posted 14 December 2013 - 07:30 PM
Could we get a tutorial and/or the scripts you're using server-side? The website directory? I just want to see how the current code works messy or not and host it on my server so it's more reliable for me.
Edit: When I try to use the API to just get a key, it errors with cannot connect to the server, too.
Edited on 14 December 2013 - 06:37 PM
463 posts
Location
Germany
Posted 15 December 2013 - 08:01 AM
it's because he's missing an / in the serv variable.
It tries to connect to "
http://zn.fluidnode.comobtain" instead of "
http://zn.fluidnode.com/obtain".
EDIT:
zn.fluidnode.com/sendSends a message to session id's channel.
Does that mean I'm sending messages to a session ID, instead of sending them to a channel?
I thought it works like rednet, multiple computers can join a channel and they only receive messages from this channel.
What is a session ID then?
Edited on 15 December 2013 - 08:48 AM
301 posts
Location
Whenever, Wherever!
Posted 15 December 2013 - 04:24 PM
I fixed the code on pastebin. Not missing a / anymore. Lemme post the code.
Server in node.js(uses private base library):
http://pastebin.com/9sV3ws4iA session id is basicly an inbox.
Also updated tutorial to be more clear.
Edited on 15 December 2013 - 03:26 PM
463 posts
Location
Germany
Posted 16 December 2013 - 08:51 AM
Polling / Sending still doesn't work, "Unable to connect to server". Also, calling the poll/send URL's in browser works.
It seems like CC interprets 4xx status codes as a http_failure, you should set the status codes to 200 instead of 4xx in your Server, then I'm sure it'll work.
301 posts
Location
Whenever, Wherever!
Posted 17 December 2013 - 05:25 PM
I hate http. xD. Should be fixed soon.
463 posts
Location
Germany
Posted 18 December 2013 - 02:48 PM
still doesn't work for me, "query invalid" :P/>
Got it working using this function instead of http.post in "aObtain" (not needed there), "aPoll" and "aSend":
Spoiler
local function fetch(url, params)
if params then
params = "?"..params
else
params = ""
end
url = url..params
http.request(url)
while true do
local ev, p1, p2 = os.pullEvent()
if ev == "http_success" then
return p2
elseif ev == "http_failure" then
return
end
end
end
Edited on 18 December 2013 - 01:49 PM
301 posts
Location
Whenever, Wherever!
Posted 19 December 2013 - 10:42 PM
This was a server-side issue where it wasn't parsing POST correctly. I didn't use GET for security reasons. I want to get an HTTPS cert for my domain but for now, oh well. All fixed now. No modified client is needed.
463 posts
Location
Germany
Posted 21 December 2013 - 06:02 AM
Thanks, I think it works now :)/>