whoami1337 1 rok temu
rodzic
commit
69e32287f9
2 zmienionych plików z 29 dodań i 27 usunięć
  1. 28 0
      README.md
  2. 1 27
      main.lua

+ 28 - 0
README.md

@@ -0,0 +1,28 @@
+# Lua Websocket for Quik
+
+### Базовая инициализация
+```
+local WebSocketClient = require('websocket')
+local copas = require "copas"
+
+local client = WebSocketClient.new({
+  uri = "http://localhost:3000",
+})
+
+copas.loop()
+```
+
+### Config init
+```
+on_connected -> callback of connected init
+on_disconnected -> callback of disconnected
+on_received(data) -> callback of recevied messages from ws server
+```
+
+### Send Websocket Message To Server
+```
+function WebSocketClient:send(command, data)
+
+command -> string,
+data -> any
+```

+ 1 - 27
main.lua

@@ -1,35 +1,9 @@
 local copas = require "copas"
-local cjson = require("cjson")
 local WebSocketClient = require('websocket')
 
 
--- local client = WebSocketClient.new("ws://localhost:1337", on_received = custom_on_received)
 local client = WebSocketClient.new({
   uri = "http://localhost:3000",
 })
-print("test")
-function delayed_function()
-  local message = {
-    event = "demo",
-    data = "Hello from Lua!"
-  }
-  local message_json = cjson.encode(message)
-  client:send(message_json)
-end
 
-print("test")
-delayed_function();
-copas.loop()
-
-
--- events: (вызов функций)
---connect
---disconnect
---received
-
--- send
- 
--- будет 2 типа сообщенгий
--- приветственное сообщение
--- сообщения заявок
--- обезлитченные сделки
+copas.loop()