Update readme and the other thing

This commit is contained in:
Christopher Cookman 2024-09-04 13:37:58 -06:00
parent af26ff5dd5
commit 256ab53998
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 46 additions and 4 deletions

View file

@ -1,2 +1,45 @@
# Websocket Client for Roblox # Websocket Client for Roblox
TODO: Detailed instructions on how to use this module will be added soon.
## 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
```lua
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
```lua
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
```lua
server.sendMessage("Hello World")
```
### server.close
```lua
server.close()
```

View file

@ -1,7 +1,6 @@
local Base64 = require(script.Base64) local Base64 = require(script.Parent:WaitForChild("Base64"))
local JobId = game:GetService('HttpService'):GenerateGUID(false) local JobId = game:GetService('HttpService'):GenerateGUID(false)
local config = require(script.Parent.Parent:WaitForChild("Configuration")) local BaseUrl = "https://sock.kcadev.org"
local BaseUrl = config["websocket-proxy"]
local atob = Base64.atob local atob = Base64.atob
local btoa = Base64.btoa local btoa = Base64.btoa
local messages = {} local messages = {}