276 posts
Location
Fairbanks, Alaska
Posted 31 May 2016 - 12:38 AM
I'm in a collab with multiple people where we create a web browser, chatting over HTTP, that stuff in ComputerCraft. Since this will require a server to be able to run, I need to figure out how I would create a real-world Lua script that runs constantly. In more simple words, a Lua web-socket server. This doesn't seem like the hardest task for ONE chatroom for testing, I can make this more advanced when I figure out how. I have Lua installed on my computer, so I should be able to test out a running server. All I really need to know is a sort of I/O Lua server, so basically I only need a snippet of code where you can send a request through CC, containing a username and a message, and have the server return what you sent. I should be able to figure it out from there.
P.S. please do not say "Google is your friend", because all I find is Gmod tutorials, and if you cannot help or don't have a suggestion, please don't say anything similar to that for that is not courteous. Also I doubt that abides with the rules of the Ask a Pro format, where you cannot have short messages, besides "Thanks"
Thanks for helping :)
-Bird
Edited on 30 May 2016 - 10:40 PM
3057 posts
Location
United States of America
Posted 31 May 2016 - 12:59 AM
You might try
makoserver. It's got an API for server-side lua. It even has a
tutorial!
Of course, this was literally the
first result from google. So, while I'm not going to say it, it is true ;)/>
212 posts
Location
Somewhere in this dimension... I think.
Posted 31 May 2016 - 01:12 AM
LuaSocket is what you need. I've been experimenting with LÖVE 2D Engine and that uses LuaSocket, though I can't say I have succeeded :)/> it definitely has all you need.
Edited on 30 May 2016 - 11:13 PM
276 posts
Location
Fairbanks, Alaska
Posted 31 May 2016 - 02:33 AM
You might try
makoserver. It's got an API for server-side lua. It even has a
tutorial!
Of course, this was literally the
first result from google. So, while I'm not going to say it, it is true ;)/>
While this is a bit confusing at first, I'm starting to like it :D/>
It looks a lot like the FS API, the only thing I'm wondering is how I would connect to this with CC, would I use http.post? .get? It uses the ws prefix. I'm not the best with jQuery so I prefer to stick with Lua if possible. By that I mean I if I have to use a more indirect method for this, such as a PHP script, that runs the JavaScript. I'm good at JavaScript, but I think it would be more complicated to use the indirect method. Although it DOES look interesting.
Edited on 31 May 2016 - 12:50 AM
3057 posts
Location
United States of America
Posted 31 May 2016 - 02:39 AM
It'd be http.get or http.post, depending on what you want to do. In general, http.get is for "getting" information from the server, whereas http.post is "sending" information - although they can each can be used for both. I really have no idea how makoserver handles GET or POST requests though.
276 posts
Location
Fairbanks, Alaska
Posted 31 May 2016 - 02:54 AM
It'd be http.get or http.post, depending on what you want to do. In general, http.get is for "getting" information from the server, whereas http.post is "sending" information - although they can each can be used for both. I really have no idea how makoserver handles GET or POST requests though.
Do you know how getting a message is handled? Sorry I can't find it in the tutorial :P/>