From cd50707b161a06af2f83bb2774835d053b7887b8 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 13 Apr 2018 20:23:55 +0900 Subject: [PATCH] ing --- servlet/auth-servlet.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/servlet/auth-servlet.go b/servlet/auth-servlet.go index ce7e3fb..d198ef3 100644 --- a/servlet/auth-servlet.go +++ b/servlet/auth-servlet.go @@ -150,6 +150,8 @@ func (s *AuthServlets) OnDisconnect(servletCtx server.ServletCtx) { } func (s *AuthServlets) handleSubscribe(serverCtx server.ServerCtx, subscribeChan <-chan *ogs.Message) { + var sessions []*ogrs.Session + LOOP: for { select { @@ -160,17 +162,20 @@ LOOP: switch msg.TargetType { case ogs.PROBE: - sessions := s.getAuthSessions(msg.Targets) - if nil == sessions || 0 == len(sessions) { - continue LOOP - } + sessions = s.getAuthSessions(msg.Targets) + default: + logging.Logger().Warnf("Subscriber: Unknown TargetType %s", msg.TargetType) + continue LOOP + } + if nil == sessions || 0 == len(sessions) { + continue LOOP + } - for _, session := range sessions { - _writeChan := session.ServletCtx.GetAttribute(og.SessionWriteChanKey) - if nil != _writeChan { - writeChan := _writeChan.(chan<- []byte) - writeChan <- *msg.Message - } + for _, session := range sessions { + _writeChan := session.ServletCtx.GetAttribute(og.SessionWriteChanKey) + if nil != _writeChan { + writeChan := _writeChan.(chan<- []byte) + writeChan <- *msg.Message } } }