-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathserver_events.go
38 lines (31 loc) · 913 Bytes
/
server_events.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
27
28
29
30
31
32
33
34
35
36
37
38
package sio
type (
ServerNewNamespaceFunc func(namespace *Namespace)
ServerAnyConnectionFunc func(namespace string, socket ServerSocket)
)
func (s *Server) OnNewNamespace(f ServerNewNamespaceFunc) {
s.newNamespaceHandlers.on(&f)
}
func (s *Server) OnceNewNamespace(f ServerNewNamespaceFunc) {
s.newNamespaceHandlers.once(&f)
}
func (s *Server) OffNewNamespace(_f ...ServerNewNamespaceFunc) {
f := make([]*ServerNewNamespaceFunc, len(_f))
for i := range f {
f[i] = &_f[i]
}
s.newNamespaceHandlers.off(f...)
}
func (s *Server) OnAnyConnection(f ServerAnyConnectionFunc) {
s.anyConnectionHandlers.on(&f)
}
func (s *Server) OnceAnyConnection(f ServerAnyConnectionFunc) {
s.anyConnectionHandlers.once(&f)
}
func (s *Server) OffAnyConnection(_f ...ServerAnyConnectionFunc) {
f := make([]*ServerAnyConnectionFunc, len(_f))
for i := range f {
f[i] = &_f[i]
}
s.anyConnectionHandlers.off(f...)
}