Implemented chatting room (#17)

This commit is contained in:
Particle_G
2020-12-03 16:09:25 +08:00
committed by MrZ626
parent 325c544e17
commit 37d7dd5fe0
11 changed files with 189 additions and 66 deletions

View File

@@ -1,27 +1,8 @@
local function send()
local W=WIDGET.active.text
--sendMessage(W.value)
W.value=""
end
function sceneInit.chat()
BG.set("none")
end
local function socketConnect()
wsConnect(
TICK.wsCONN_connect,
"/solo?room_id=114",
{}
)
end
local function socketWrite()
local function socketWrite(message)
if not WSCONN then
LOG.print("尚未连接到服务器","warn")
return
end
local message = WIDGET.active.message.value
print("TextBox: "..message)
local writeErr = client.write(WSCONN, message)
if writeErr then
print(writeErr, "warn")
@@ -29,6 +10,21 @@ local function socketWrite()
return true
end
local function send()
local W=WIDGET.active.text
socketWrite(W.value)
W.value=""
end
function sceneInit.chat()
BG.set("none")
wsConnect(
TICK.wsCONN_connect,
PATH.socket..PATH.chat.."?email="..urlEncode(ACCOUNT.email).."&access_token="..urlEncode(ACCOUNT.access_token),
{}
)
end
WIDGET.init("chat",{
WIDGET.newTextBox{name="text", x=40, y=500,w=980,h=180,font=40},
WIDGET.newButton{name="send", x=1140, y=540,w=170,h=80,font=40,code=send},