mirror of
https://github.com/raz-varren/sacrificial-socket.git
synced 2025-10-07 00:52:48 +08:00
add broadcast/roomcast to server struct so they can be used outside of socket events
This commit is contained in:
10
server.go
10
server.go
@@ -131,6 +131,16 @@ func (serv *SocketServer) SetMultihomeBackend(b MultihomeBackend) {
|
||||
serv.hub.setMultihomeBackend(b)
|
||||
}
|
||||
|
||||
//Roomcast dispatches an event to all Sockets in the specified room.
|
||||
func (serv *SocketServer) Roomcast(roomName, eventName string, data interface{}) {
|
||||
serv.hub.roomcast(&RoomMsg{roomName, eventName, data})
|
||||
}
|
||||
|
||||
//Broadcast dispatches an event to all Sockets on the SocketServer.
|
||||
func (serv *SocketServer) Broadcast(eventName string, data interface{}) {
|
||||
serv.hub.broadcast(&BroadcastMsg{eventName, data})
|
||||
}
|
||||
|
||||
//loop handles all the coordination between new sockets
|
||||
//reading frames and dispatching events
|
||||
func (serv *SocketServer) loop(ws *websocket.Conn) {
|
||||
|
Reference in New Issue
Block a user