File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
new/client/templates/wrappers Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,24 @@ func ReconnectGame(username string) (*Game, error) {
75
75
}, nil
76
76
}
77
77
78
+ // Spectate joins a game as a spectator.
79
+ func Spectate(gameId string) (*Game, error) {
80
+ socket, err := cg.NewSocket("{{.URL}}")
81
+ if err != nil {
82
+ return nil, fmt.Errorf("failed to connect to server: %s", err)
83
+ }
84
+
85
+ err = socket.Spectate(gameId)
86
+ if err != nil {
87
+ return nil, fmt.Errorf("failed to spectate game: %s", err)
88
+ }
89
+
90
+ return &Game{
91
+ Id: socket.Session().GameId,
92
+ socket: socket,
93
+ }, nil
94
+ }
95
+
78
96
// Run starts the event loop (blocking).
79
97
func (g *Game) Run() error {
80
98
return g.socket.RunEventLoop()
@@ -89,6 +107,16 @@ func (g *Game) Update() error {
89
107
return err
90
108
}
91
109
110
+ // ResolveUsername returns the username associated with playerId.
111
+ func (g *Game) ResolveUsername(playerId string) string {
112
+ return g.socket.ResolveUsername(playerId)
113
+ }
114
+
115
+ // Session returns details of the current session.
116
+ func (g *Game) Session() cg.Session {
117
+ return g.socket.Session()
118
+ }
119
+
92
120
// Disconnect closes the underlying socket connection.
93
121
func (g *Game) Disconnect() error {
94
122
return g.socket.Close()
Original file line number Diff line number Diff line change 1
1
{
2
2
"server" : {
3
- "0.7" : " 0.1 "
3
+ "0.7" : " 0.2 "
4
4
},
5
5
"client" : {
6
- "0.8" : " 0.1 "
6
+ "0.8" : " 0.2 "
7
7
}
8
8
}
You can’t perform that action at this time.
0 commit comments