MWSE/internal/services/yourid.go

12 lines
362 B
Go

package services
import "git.saqut.com/saqut/mwse/internal/ws"
// registerYourID tells a freshly connected client its own socket id, exactly as
// the Node YourID service did: client.send([{type:'id', value: id}, 'id']).
func registerYourID(hub *ws.Hub) {
hub.OnConnect(func(c *ws.Client) {
c.Signal("id", map[string]any{"type": "id", "value": c.ID})
})
}