Samir
The code above throws an error when run through the command line:
D:\xwapp\luart\LuaRT-Studio>luart untitled.lua
untitled.lua:2: module 'socket' not found:
no field package.preload['socket']
no file 'D:\xwapp\luart\bin\lua\socket.lua'
no file 'D:\xwapp\luart\bin\lua\socket\init.lua'
no file 'D:\xwapp\luart\bin\socket.lua'
no file 'D:\xwapp\luart\bin\socket\init.lua'
no file 'D:\xwapp\luart\bin\..\modules\socket\socket.lua'
no file 'D:\xwapp\luart\bin\..\modules\socket\init.lua'
no file '.\socket.lua'
no file '.\socket.wlua'
no file '.\socket\init.lua'
no file 'D:\xwapp\luart\bin\lua\socket.wlua'
no file 'D:\xwapp\luart\bin\socket.wlua'
no file 'D:\xwapp\luart\bin\..\modules\socket\socket.wlua'
no file '.\socket.wlua'
no file ''
no file 'D:\xwapp\luart\bin\socket.dll'
no file 'D:\xwapp\luart\bin\..\lib\lua\5.4\socket.dll'
no file 'D:\xwapp\luart\bin\..\modules\socket\socket.dll'
no file 'D:\xwapp\luart\bin\loadall.dll'
no file '.\socket.dll'
no file ''
D:\xwapp\luart\LuaRT-Studio>where luart
D:\xwapp\luart\bin\luart.exe
I'm looking for an example of connecting to a luart WebSocket (ws) service using JavaScript.
After running LuaRT-Studio/examples/net/chatserver.lua, I'm unable to connect to it using JavaScript.
// Run this in a browser tab under http protocol
function startWs(wsLink){
window.ws = new WebSocket(wsLink)
ws.onopen = (evt) => {
ws.send(`client send`)
}
ws.onmessage = (evt) => {
console.log( `serve get`, evt.data)
}
}
startWs(`ws://127.0.0.1:5000`)
However, the JavaScript code above can successfully connect to a WebSocket service created by Node.js Express.
by luart v1.9.0