Skip to content

Commit 8d6e9cf

Browse files
intel352claude
andcommitted
feat: export JoinRoom/LeaveRoom on hub to satisfy extended WSHub interface
The gameserver plugin's WSHub interface now requires JoinRoom and LeaveRoom so spectator steps can manage room membership. Add exported wrappers on hub and update the package-level Hub interface to match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f14ad07 commit 8d6e9cf

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

internal/hub.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ func (h *hub) broadcastToRoom(room string, msg []byte, exclude string) {
157157
}
158158
}
159159

160+
// JoinRoom adds connID to the named room. Returns true if the connection was registered.
161+
// This satisfies the gameserver plugin's ws_bridge.WSHub interface.
162+
func (h *hub) JoinRoom(connID, room string) bool {
163+
return h.joinRoom(connID, room)
164+
}
165+
166+
// LeaveRoom removes connID from the named room.
167+
// This satisfies the gameserver plugin's ws_bridge.WSHub interface.
168+
func (h *hub) LeaveRoom(connID, room string) {
169+
h.leaveRoom(connID, room)
170+
}
171+
160172
// BroadcastToRoom sends msg to all connections in room, returning the recipient count.
161173
// This satisfies the gameserver plugin's ws_bridge.WSHub interface.
162174
func (h *hub) BroadcastToRoom(room string, msg []byte) int {

plugin.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ func NewWebSocketPlugin() sdk.PluginProvider {
1111
return internal.NewWebSocketPlugin()
1212
}
1313

14-
// Hub is an exported interface for the WebSocket hub's broadcast capabilities.
14+
// Hub is an exported interface for the WebSocket hub's room and broadcast capabilities.
1515
// Satisfied by the internal hub after the ws.server module is initialized.
1616
type Hub interface {
1717
BroadcastToRoom(room string, msg []byte) int
18+
JoinRoom(connID, room string) bool
19+
LeaveRoom(connID, room string)
1820
}
1921

2022
// GetHub returns the global WebSocket hub once the ws.server module has been

0 commit comments

Comments
 (0)