Página 1 de 1

Lua WebSocket Client

Publicado: 29 Jun 2016 22:07
por Pabloko
WebSocket Lua Module
Este módulo para luajit (supongo que debe funcionar con lua vm...) permite conectar contra un servidor websocket , enviar y recibir información en tiempo real.

Esta lib esta basada en el proyecto easywebsocketclient (https://github.com/dhbaird/easywsclient) y tiene un funcionamiento minimo para conectar, desconectar, enviar un string, recibir un string y comprobar el estado de la conexión.

Todo lo necesario para usarlo lo podeis ver en test.lua, podeis usar test.bat para ejecutar el test y verlo funcionando contra el servidor echo de websocket.org, el cual simplemente responde el mensaje que envias.

Para la parte de servidor, hay muchas opciones, pero yo recomiendo solamente 2:

- Si tu servidor no necesita intercambiar información entre usuarios conectados y solo realiza operaciones en el servidor, lo mejor es utilizar websocketd (http://websocketd.com/) el cual te permite crear un servidor websocket a partir de cualquier script que use stdin y stdout, por ejemplo scripts lua.
-Si tu servidor intercambia informacion entre usuarios, como un chat, y dispone de funcionalidades mas complejas, recomiendo usar nodejs+ws, por ejemplo este proyecto (https://github.com/0x1d/nodejs-ws-chat) si mirais los issues publique uno para añadir interfaz http sobre el puerto websocket (https://github.com/0x1d/nodejs-ws-chat/issues/1).

Este es el ejemplo del testsuite:
Imagen

WebSocket Lua Module
This luajit module (i suppuse it should work with standard vm too...) allows to connect, send and recieve data from a websocket server. it acts as websocket client.

This library is based on easywebsocketclient (https://github.com/dhbaird/easywsclient) it has minimal api to connect, disconnect, send strings, recieve strings, and check connection status.

All api is referenced on test.lua, you can use test.bat to execute a test script that connects to echo server on websocket.org, it just reply the messages you send.

For the server part theres lot of websocket servers but i highly recommend this:

- If your server dont need to share info between connected users, and it simply executes scripts on server, use websocketd (http://websocketd.com/) it allow to create a websocket server from any script in any language that supports stdin and stdout, like lua with io.read/write
-If your server share info between connected users, like a chat, and make more complex routines, use nodejs+ws, this chat project can be used to test (https://github.com/0x1d/nodejs-ws-chat) also websocket server can stream http static websites over http, see my issue on the repo to do it (https://github.com/0x1d/nodejs-ws-chat/issues/1).

HIDE: ON
Hidebb Message Hidden Description

Re: Lua WebSocket Client

Publicado: 30 Jun 2016 09:02
por rafaxplayer
hala ya podeis hacer un chat en ams , si no arde antes claro....

Re: Lua WebSocket Client

Publicado: 10 Jul 2016 02:27
por patch
So this acts like the websockets in chrome and firefox? and could they work togeather so a chat in the brower could talk to the lua websocket?

Re: Lua WebSocket Client

Publicado: 11 Jul 2016 15:39
por Pabloko
yes, read the description... is self explanatory.

btw tests shown it can handle 120kb of data on each packet. (at least with echo server, on code side rxbuf seems to grow to infinite if we want)

Re: Lua WebSocket Client

Publicado: 19 Jul 2016 02:39
por andrea
:friends: :friends: :friends: :friends:

Re: Lua WebSocket Client

Publicado: 29 Dic 2016 19:15
por Guanj
gracias

Re: Lua WebSocket Client

Publicado: 18 May 2017 21:08
por ByPoLaT
thanks..

Re: Lua WebSocket Client

Publicado: 01 Jun 2017 07:29
por nghethihieu
GREAT!!!

Re: Lua WebSocket Client

Publicado: 11 Sep 2017 23:09
por oussemaTN
thnksssssssssss

Re: Lua WebSocket Client

Publicado: 28 Dic 2019 02:22
por erol1985
thanks you

Re: Lua WebSocket Client

Publicado: 28 Dic 2019 15:40
por sendai
gracias

Re: Lua WebSocket Client

Publicado: 02 Ene 2021 12:23
por salim1313131sss
:lol: :lol:

Re: Lua WebSocket Client

Publicado: 09 Feb 2021 06:49
por pexabosh
gracias