mirror of
https://github.com/raz-varren/sacrificial-socket.git
synced 2025-10-07 17:11:00 +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)
|
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
|
//loop handles all the coordination between new sockets
|
||||||
//reading frames and dispatching events
|
//reading frames and dispatching events
|
||||||
func (serv *SocketServer) loop(ws *websocket.Conn) {
|
func (serv *SocketServer) loop(ws *websocket.Conn) {
|
||||||
|
Reference in New Issue
Block a user