ComputerCraft

ComputerCraft

21M Downloads

Suggestion - Web Sockets

dmarcuse opened this issue ยท 8 comments

commented

Seeing as we're getting new features added now, I'd like to suggest websockets. They've been suggested on the forums in the past, and would be a much better way to maintain communication with a server compared to the current method of long-polling HTTP requests, as seen in jamROGUE. They're also significantly easier to restrict than raw TCP sockets, which would be good for server admins, and can also support SSL for security.

There's a forum thread suggesting them, and they've also been implemented in CCTweaks by @SquidDev already which makes it really easy to port over to the core mod.

commented

I want to add here that adding sockets would allow so many fun and joyfull projects that let computercraft to interact with outside world like this thing or this without those long-polling HTTP requests that noone likes and everyone that tries to make something like this has to use to get any kind of good communication (and handling code for them always end up as spaghetti code).

commented

You could write full Discord clients too then. Something I might actually do lol

commented

@MagnificentPako ah. It would be insecure any way you do it due to storing the token on the computer...

commented

@MagnificentPako can you not already with use of the HTTP API? Discord uses a REST API iirc. However, I would not want to put a token in ComputerCraft.

commented

@Restioson sure, you can do a lot with the REST API. But the discord devs will get really annoyed if you use the REST API for repeatedly polling messages. That's what the WS gateway is for, mostly. It also provides live events etc.

commented

I've been working on #170, sorry for taking so long ๐Ÿ˜›

commented

Just wanted to add my support to this feature and provide a link to the aforementioned socket code in CCTweaks: https://github.com/SquidDev-CC/CCTweaks-Lua/tree/master/src/main/java/org/squiddev/cctweaks/lua/lib/socket

commented

@dunstad I'm planning to PR it in at some point. I want to wait until #170 gets implemented though, as it'll use the same system for blacklisting websockets.