This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

How to use android app to control LM
#11
(28.04.2021, 05:31)admin Wrote: You can use a WebSocket connection to read/write object values. There are built-in JavaScript libraries in LM that can be used in your app if using Cordova (https://cordova.apache.org/) instead of native Android app SDK. See this thread for more info: https://forum.logicmachine.net/showthread.php?tid=525

Hi Admin,

Let me understand.
If I am going to implement a websocket server in LM, I first create a resident script with this script under:
Do I have to change anything in this script or add something? 

Code:
local copas = require'copas'

-- create a copas webserver and start listening
local server = require'websocket'.server.copas.listen
{
  -- listen on port 8080
  port = 8080,
  -- the protocols field holds
  --   key: protocol name
  --   value: callback on new connection
  protocols = {
    -- this callback is called, whenever a new client connects.
    -- ws is a new websocket instance
    echo = function(ws)
      while true do
        local message = ws:receive()
        if message then
           ws:send(message)
        else
           ws:close()
           return
        end
      end
    end
  }
}

-- use the copas loop
copas.loop()
Reply


Messages In This Thread
RE: How to use android app to control LM - by Alexander - 11.05.2021, 20:58

Forum Jump: