Fixes
This commit is contained in:
parent
5a2a368b9e
commit
c5e7f6c545
|
@ -70,6 +70,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var r com.RegisteredUser
|
var r com.RegisteredUser
|
||||||
|
var tmpLink *com.Link
|
||||||
|
|
||||||
func readFromServer(conn net.Conn, ws *websocket.Conn) {
|
func readFromServer(conn net.Conn, ws *websocket.Conn) {
|
||||||
buf := make([]byte, 70000)
|
buf := make([]byte, 70000)
|
||||||
|
@ -96,6 +97,12 @@ func readFromServer(conn net.Conn, ws *websocket.Conn) {
|
||||||
r.ID = newID
|
r.ID = newID
|
||||||
r.IsRegistered = true
|
r.IsRegistered = true
|
||||||
break
|
break
|
||||||
|
case com.ID_SERVER_APPROVE_CLIENT_LINK:
|
||||||
|
if tmpLink == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
msg.ToID = tmpLink.UseCount
|
||||||
|
msg.Data = tmpLink.Data
|
||||||
}
|
}
|
||||||
log.Printf("client: readServer: sending message to websocket: %v", *msg)
|
log.Printf("client: readServer: sending message to websocket: %v", *msg)
|
||||||
ws.WriteJSON(*msg)
|
ws.WriteJSON(*msg)
|
||||||
|
@ -113,12 +120,16 @@ func readFromWebSocket(conn net.Conn, ws *websocket.Conn) {
|
||||||
log.Printf("client: readWS: received message from Electron: %v", msg)
|
log.Printf("client: readWS: received message from Electron: %v", msg)
|
||||||
msg.Version = com.V1
|
msg.Version = com.V1
|
||||||
switch msg.ID {
|
switch msg.ID {
|
||||||
case com.ID_CLIENT_ASK_SERVER_LINK:
|
case com.ID_CLIENT_SEND_SERVER_LINK:
|
||||||
|
if !r.IsRegistered {
|
||||||
|
continue
|
||||||
|
}
|
||||||
l, err := r.GenerateLink(msg.ToID)
|
l, err := r.GenerateLink(msg.ToID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error: link: %v", err)
|
log.Printf("Error: link: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
tmpLink = &l
|
||||||
answ, err := com.ClientSendServerLink(l)
|
answ, err := com.ClientSendServerLink(l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error: com: %v", err)
|
log.Printf("Error: com: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user