-
Notifications
You must be signed in to change notification settings - Fork 0
/
channel.go
26 lines (19 loc) · 937 Bytes
/
channel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package larasockets
// Channel interface defines the methods required for a channel to implement.
type Channel interface {
// Name returns the name of the channel
Name() string
// Connections returns all the concurrent connections to this channel
Connections() []Connection
// Subscribe subscribes a new connection to the channel
Subscribe(conn Connection, payload interface{})
// Unsubscribe removes the connection from the current subscribed connections
UnSubscribe(conn Connection)
// IsSubscribed returns if the given connection is already subscribed to this channel
IsSubscribed(conn Connection) bool
// Broadcast sends the data to all the connected connections
Broadcast(data interface{})
// BroadcastExcept sends the data to all the connected connections except the given
// connection. Usually its the connection who initiated the broadcast.
BroadcastExcept(data interface{}, excludedConnectionId string)
}