Network
Make HTTP requests and open WebSocket connections.
Lynx scripts can talk to any server on the internet, in any experience, whether or not the game has HTTP requests enabled.
HTTP
request
since 1.0.0Yieldsrequest(options: RequestOptions): ResponseSends an HTTP request and yields until the response arrives.
Unlike HttpService, it also sends PUT, PATCH and DELETE and returns the full response, including status and headers, even when the server responds with an error. For a quick GET that only needs the body, game:HttpGet(url) also works.
Also available as http_request and http.request.
Parameters
optionsRequestOptions- What to send. See RequestOptions.
Returns
ResponseThe server's response. See Response.
Example
RequestOptions
UrlstringMethodstring?GET (the default), POST, PUT, PATCH or DELETE. Anything else raises an error.Headers{ [string]: string }?Cookie header.Bodystring?POST, PUT and PATCH.Response
Successbooleantrue when StatusCode is between 200 and 299.StatusCodenumberStatusMessagestring"Not Found".Headers{ [string]: string }BodystringErrorstringDefault headers
Lynx adds three headers to every request, so servers can tell Lynx traffic apart. A header of the same name in Headers replaces it.
WebSocket
WebSocket.connect
since 1.0.0YieldsWebSocket.connect(url: string): WebSocketOpens a WebSocket connection to url and yields until it's established. Errors if the connection can't be made.
Parameters
urlstring- A
ws://orwss://URL.
Returns
WebSocketThe open connection. See WebSocket object.
Example
WebSocket object
Send(message: string)Close()OnClose fires.OnMessage(message: string)OnClose()Written for Lynx 0.0.0
Something unclear? Tell us on Discord