Compatibility
Minecraft: Java Edition
Platforms
Supported environments
Links
Tags
Creators
Details
VERY WORK-IN-PROGRESS
A figura addon that allows you to open and use TCP sockets.
You can contact me at ktzukii on Discord if the mod crashes your game, or doesn't work as intended.
(please attach the logs on the message, if not you're getting a "invalid, read description")
Documentation:
SocketAPI (global socket)
These functions WILL return nil if the client (game) running the avatar (your scripts and model) is not the host (eg. your game will return a LuaSocket instance, others will return nil.)
So please add host checks on your socket scripts, otherwise your avatar will error on other clients, and will cause unneccesary trouble and confusion.
SocketAPI:newSocket(String host, Number port) -> LuaSocket
Opens a new socket, will print errors in log or throw vm error.
SocketAPI:newWebsocket(String host, Number port) -> LuaWebsocket
Opens a new websocket, will print errors in log or throw vm error.
SocketAPI:closeAllSocket()
Close all sockets on the current avatar
SocketAPI:closeAllWebsocket()
Close all websockets on the current avatar
SocketAPI:closeAll() -> nil
Closes all sockets and/or websockets on the current avatar
LuaSocket
LuaSocket:send(String data) -> nil
Sends data, limited to strings due to how I wrote this mod. (working on changing that)
LuaSocket:recv() -> string
Recieves data, also limited to strings. (see above)
LuaSocket:hasData() -> boolean
Gets whether or not there is a message to be received, which can then be gotten by LuaSocket:recv()
Luasocket:close() -> nil
Sockets close automatically on avatar destroy/reload, but it's not a clean close, which is what this is for.
LuaWebsocket
Websockets are known to be buggy at this time.
LuaWebsocket:send(String data) -> nil
Sends data, limited to strings due to my understanding of Java.
LuaWebsocket:recv() -> string
Recieves data, also limited to strings. (see above)
LuaWebsocket:hasData() -> boolean
Gets whether or not there is a message to be received, which can then be gotten by LuaWebsocket:recv()
LuaWebsocket:close(String reason) -> nil
Websockets close automatically on avatar destroy/reload, but it's not a clean close, which is what this is for.
Examples:
REMOVED: My examples suck :3 I'll try to add some examples on the github wiki, but no promises.


