hell yeah i love canvas rendering
This commit is contained in:
parent
3f3164bc15
commit
ecda8dde24
3 changed files with 188 additions and 200 deletions
|
@ -17,8 +17,9 @@ type CursorClient struct {
|
|||
ID int32
|
||||
Conn *websocket.Conn
|
||||
Route string
|
||||
X int16
|
||||
Y int16
|
||||
X float32
|
||||
Y float32
|
||||
Click bool
|
||||
Disconnected bool
|
||||
}
|
||||
|
||||
|
@ -91,7 +92,7 @@ func handleClient(client *CursorClient) {
|
|||
if otherClient.ID == client.ID { continue }
|
||||
if otherClient.Route != client.Route { continue }
|
||||
client.Send([]byte(fmt.Sprintf("join:%d", otherClient.ID)))
|
||||
client.Send([]byte(fmt.Sprintf("pos:%d:%d:%d", otherClient.ID, otherClient.X, otherClient.Y)))
|
||||
client.Send([]byte(fmt.Sprintf("pos:%d:%f:%f", otherClient.ID, otherClient.X, otherClient.Y)))
|
||||
}
|
||||
mutex.Unlock()
|
||||
broadcast <- CursorMessage{
|
||||
|
@ -118,15 +119,26 @@ func handleClient(client *CursorClient) {
|
|||
client.Route,
|
||||
[]*CursorClient{ client },
|
||||
}
|
||||
case "click":
|
||||
if len(args) < 2 { return }
|
||||
click := 0
|
||||
if args[1][0] == '1' {
|
||||
click = 1
|
||||
}
|
||||
broadcast <- CursorMessage{
|
||||
[]byte(fmt.Sprintf("click:%d:%d", client.ID, click)),
|
||||
client.Route,
|
||||
[]*CursorClient{ client },
|
||||
}
|
||||
case "pos":
|
||||
if len(args) < 3 { return }
|
||||
x, err := strconv.ParseInt(args[1], 10, 32)
|
||||
y, err := strconv.ParseInt(args[2], 10, 32)
|
||||
x, err := strconv.ParseFloat(args[1], 32)
|
||||
y, err := strconv.ParseFloat(args[2], 32)
|
||||
if err != nil { return }
|
||||
client.X = int16(x)
|
||||
client.Y = int16(y)
|
||||
client.X = float32(x)
|
||||
client.Y = float32(y)
|
||||
broadcast <- CursorMessage{
|
||||
[]byte(fmt.Sprintf("pos:%d:%d:%d", client.ID, client.X, client.Y)),
|
||||
[]byte(fmt.Sprintf("pos:%d:%f:%f", client.ID, client.X, client.Y)),
|
||||
client.Route,
|
||||
[]*CursorClient{ client },
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue