|
@@ -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()
|