1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

websocket: eventbus and other cleanup

This commit is contained in:
Abdullah Atta
2020-04-09 00:19:01 +05:00
committed by GitHub
parent b40fdd9089
commit 6f8f8d7b1b
3 changed files with 27 additions and 38 deletions

View File

@@ -40,7 +40,8 @@ struct Fragment {
code OPCode
}
struct Message {
pub struct Message {
pub:
opcode OPCode
payload voidptr
payload_len int
@@ -117,12 +118,18 @@ fn (ws &Client) parse_uri() &Uri {
}
pub fn (ws mut Client) connect() int {
if ws.state == .connected {
l.f("connect: websocket already connected")
} else if ws.state == .connecting {
l.f("connect: websocket already connecting")
} else if ws.state == .open {
l.f("connect: websocket already open")
match ws.state {
.connected {
l.f("connect: websocket already connected")
}
.connecting {
l.f("connect: websocket already connecting")
}
.open {
l.f("connect: websocket already open")
} else {
// do nothing
}
}
ws.lock.lock()