Find a file
2024-09-04 13:37:58 -06:00
Base64.lua Move to separate repo 2024-09-04 07:41:25 -06:00
README.md Update readme and the other thing 2024-09-04 13:37:58 -06:00
WebSocket.lua Update readme and the other thing 2024-09-04 13:37:58 -06:00

Websocket Client for Roblox

Setup

  1. Place the WebSocket and Base64 files in ServerScriptService.
  2. Create a new script in Workspace, or wherever you want.
  3. If you are hosting your own WebSocket server, replace the URL https://sock.kcadev.org with your own.

Usage

local ws = require(game.ServerScriptService:WaitForChild("WebSocket"))
local server = ws({
	url = "wss://echo.websocket.org/",
	onMessage = function(message)
		print("Message received: " .. message)
	end,
	onError = function(error)
		print("Error: " .. error)
	end
})
server.sendMessage("Hello World")

Functions

ws

local server = ws({
	url = "wss://echo.websocket.org/",
	onMessage = function(message)
		print("Message received: " .. message)
	end,
	onError = function(error)
		print("Error: " .. error)
	end
})

server.sendMessage

server.sendMessage("Hello World")

server.close

server.close()