Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Sign in to follow this  
feldim2425

Websocket Client API

Recommended Posts

A simpe API to connect to a Websocket Server / Endpoint

Forgot to mention: This API requires a Internet Card and Lua 5.3

Example Code:

local ws = require("websocket_client");
local event = require("event");

local cl = ws.create(function(ev ,var1) print(ev .. "->" .. var1) end);

cl:connect("localhost", 12345, "/");

while true do
  local ev = {event.pull()};

  if ev[1] == "interrupted" then
    cl:disconnect();
    return;
  elseif ev[1] == "touch" then
    cl:send("HI");
  end
end

 

Full API documentation here: https://github.com/feldim2425/OC-Programs/blob/master/websocket_client/API.md

To download and install the API simply run this command:

pastebin run xnXssAtH

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.