Jump to content




WebSocket implementation


4 replies to this topic

#1 Gumball

  • Members
  • 254 posts
  • LocationFairbanks, Alaska

Posted 18 December 2016 - 06:59 AM

This would make real-time internet communication possible with CC.
There's already an open-source library for WebSockets in Java, so it wouldn't be amazingly difficult.

This would make CC more fun and practical to use. What I think it should look like:

ws = os.loadAPI("websockets")
socket  = ws.connect("ws://PlaceThatProvidesAWebSocket")
emittedEvent,data = os.pullEvent("wsreceive")

socket.emit("eventName",{packet1 = "noice"})

This was suggested a couple years ago and didn't get much attention.

"data" would either be an array or string. You'd need to decode arrays that are sent first, but that shouldn't be difficult.

Edited by BlueBird, 18 December 2016 - 07:00 AM.


#2 SquidDev

    Frickin' laser beams

  • Members
  • 1,415 posts
  • LocationDoes anyone put something serious here?

Posted 18 December 2016 - 08:02 AM

CCTweaks provides a TCP socket system. The WebSocket spec doesn't look too hard to implement and it is built on top of TCP so you could have a go at implementing an API using that :).

#3 Gumball

  • Members
  • 254 posts
  • LocationFairbanks, Alaska

Posted 18 December 2016 - 08:45 AM

I think it would be better without a mod, also I'm not very confident that I'd be able to implement that.

#4 JustPingo

  • Members
  • 108 posts
  • LocationFrance

Posted 19 December 2016 - 01:58 AM

The websocket specification isn't enormous and pretty straight forward. I'm sure you could do it.

#5 Xerxes

  • Members
  • 55 posts
  • LocationSwitchCraft

Posted 31 December 2016 - 11:40 PM

View PostJustPingo, on 19 December 2016 - 01:58 AM, said:

The websocket specification isn't enormous and pretty straight forward. I'm sure you could do it.

View PostSquidDev, on 18 December 2016 - 08:02 AM, said:

CCTweaks provides a TCP socket system. The WebSocket spec doesn't look too hard to implement and it is built on top of TCP so you could have a go at implementing an API using that :).
The WebSocket spec is a royal pain in the ass to implement in Java, so I imagine it would be even more difficult to implement in Lua.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users