This commit is contained in:
crusader 2017-08-31 20:19:59 +09:00
parent e2ef11e395
commit 177a3c9a4c
3 changed files with 6 additions and 2 deletions

View File

@ -131,7 +131,7 @@ func (s *server) Sockets() map[string]Socket {
}
func (s *server) HandleSocket(pattern string, soch SocketHandler) {
soch.(*SocketHandlers).onDisconnected = s.onDisconnected
soch.setOnDisconnected(s.onDisconnected)
soch.Validate()
s._handlers[pattern] = soch

View File

@ -12,6 +12,6 @@ type SocketHandler interface {
GetPingPeriod() time.Duration
IsBinaryMessage() bool
GetProtocol() ProtocolHandler
setOnDisconnected(cb func(soc Socket))
Validate()
}

View File

@ -61,6 +61,10 @@ func (sh *SocketHandlers) GetProtocol() ProtocolHandler {
return sh.Protocol
}
func (sh *SocketHandlers) setOnDisconnected(cb func(soc Socket)) {
sh.onDisconnected = cb
}
// Validate validates the configuration
func (sh *SocketHandlers) Validate() {
if nil == sh.Protocol {