From 9f2ff9438c24eab716dc54946ea65395d796d096 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 13 Apr 2018 20:22:50 +0900 Subject: [PATCH] ing --- servlet/probe-servlet.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/servlet/probe-servlet.go b/servlet/probe-servlet.go index 2cc8d88..5c83ff1 100644 --- a/servlet/probe-servlet.go +++ b/servlet/probe-servlet.go @@ -127,6 +127,7 @@ func (s *ProbeServlets) OnDisconnect(servletCtx server.ServletCtx) { } func (s *ProbeServlets) handleSubscribe(serverCtx server.ServerCtx, subscribeChan <-chan *ogs.Message) { + var sessions []*ogrs.Session LOOP: for { @@ -138,19 +139,24 @@ LOOP: switch msg.TargetType { case ogs.PROBE: - sessions := s.getProbeSessions(msg.Targets) - if nil == sessions || 0 == len(sessions) { - continue LOOP - } + sessions = s.getProbeSessions(msg.Targets) + default: + logging.Logger().Warnf("Subscriber: Unknown TargetType %s", msg.TargetType) + continue LOOP + } - for _, session := range sessions { - _writeChan := session.ServletCtx.GetAttribute(og.SessionWriteChanKey) - if nil != _writeChan { - writeChan := _writeChan.(chan<- []byte) - writeChan <- *msg.Message - } + 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 } } + } } }