Skip to content

Commit d7f1a42

Browse files
intel352claude
andcommitted
feat: add SendTo to Hub interface for direct WS message delivery
Expose SendTo on the public Hub interface so gameserver steps can deliver messages directly to a connection by connectionId, without requiring the connection to be in a named room. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5713e56 commit d7f1a42

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

internal/hub.go

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

160+
// SendTo delivers msg directly to a connection by connID.
161+
// Returns true if the message was queued. Satisfies the gameserver plugin's ws_bridge.WSHub interface.
162+
func (h *hub) SendTo(connID string, msg []byte) bool {
163+
return h.sendTo(connID, msg)
164+
}
165+
160166
// JoinRoom adds connID to the named room. Returns true if the connection was registered.
161167
// This satisfies the gameserver plugin's ws_bridge.WSHub interface.
162168
func (h *hub) JoinRoom(connID, room string) bool {

plugin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ func NewWebSocketPlugin() sdk.PluginProvider {
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+
// SendTo delivers a message directly to a connection by its ID.
19+
SendTo(connID string, msg []byte) bool
1820
}
1921

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

0 commit comments

Comments
 (0)