]> Sergey Matveev's repositories - vors.git/blobdiff - cmd/server/main.go
Chatting ability
[vors.git] / cmd / server / main.go
index 9ede9f61c29b3f27937506d7154b31c8315d267d9a4b8f97f575bf85fa70fbd4..75d0b078bdbdc51234e0fe2cf4c798e45dd1b62df8d0927cc02de4a30d411d85 100644 (file)
@@ -328,6 +328,18 @@ func newPeer(conn *net.TCPConn) {
                                }
                                go func(tx chan []byte) { tx <- s }(p.tx)
                        }
+               case vors.CmdChat:
+                       if len(args) != 2 {
+                               logger.Error("wrong len(args)")
+                               continue
+                       }
+                       msg := vors.ArgsEncode([]byte(vors.CmdChat), []byte{peer.sid}, args[1])
+                       for _, p := range room.peers {
+                               if p.sid == peer.sid {
+                                       continue
+                               }
+                               go func(tx chan []byte) { tx <- msg }(p.tx)
+                       }
                default:
                        logger.Error("unknown", "cmd", cmd)
                }