Pulled out common code from spectator and player

This commit is contained in:
sm
2014-02-17 00:42:52 -08:00
parent b131b4bc53
commit 5d9103f176
3 changed files with 76 additions and 94 deletions
+10 -6
View File
@@ -232,9 +232,11 @@ func addPlayer(ws *websocket.Conn) {
p := &player{
Robots: []*Robot{},
send: make(chan Message, 16),
ws: ws,
Id: player_id,
protoTalker: protoTalker{
send: make(chan Message, 16),
ws: ws,
Id: player_id,
},
}
log.Printf("%s: made a player: %s", gid.Id, p.Id)
@@ -291,9 +293,11 @@ func addPlayer(ws *websocket.Conn) {
)
case "spectator":
s := &Spectator{
send: make(chan Message, 16),
ws: ws,
Id: player_id,
protoTalker{
send: make(chan Message, 16),
ws: ws,
Id: player_id,
},
}
log.Printf("%s, %s: about to register this spectator", gid.Id, s.Id)
game.sregister <- s