Beispiel #1
0
 public bool Has(Guid guid)
 {
     using (var rlock = new ReadLock(rwLock))
     {
         return(protocols.ContainsKey(guid));
     }
 }
Beispiel #2
0
        private void OnDisconnected(Msg m)
        {
            logger.Debug($"Disconnected. Protocol: {m.Protocol.ProtocolId}");

            using (var rlock = new ReadLock(rwLock))
            {
                protocols.Remove(m.Protocol.ProtocolId);
            }
        }
Beispiel #3
0
 public void Broadcast(Msg m)
 {
     using (var rlock = new ReadLock(rwLock))
     {
         foreach (var kv in protocols)
         {
             kv.Value.Send(m);
         }
     }
 }
Beispiel #4
0
        public MsgPackProtocol Get(Guid guid)
        {
            using (var rlock = new ReadLock(rwLock))
            {
                if (protocols.ContainsKey(guid))
                {
                    return(protocols[guid]);
                }
            }

            return(null);
        }
Beispiel #5
0
        public int GetSubscriptionCount(uint msgType)
        {
            using (var rlock = new ReadLock(rwLock))
            {
                if (subs.ContainsKey(msgType))
                {
                    var typeSubs = subs[msgType];
                    return(typeSubs.GetSubscriptionCount());
                }
            }

            return(0);
        }
Beispiel #6
0
        private void OnConnected(Msg m)
        {
            var mc = (MsgConnected)m;

            logger.Debug($"Connected. Result:{mc.Result}, Protocol: {mc.Protocol.ProtocolId}");

            if (mc.Result != Result.Success && mc.Result != Result.Success_ActiveClose)
            {
                using (var rlock = new ReadLock(rwLock))
                {
                    protocols.Remove(mc.Protocol.ProtocolId);
                }
            }
        }
Beispiel #7
0
        public int Post(Msg m)
        {
            TypeSubs typeSubs = null;

            using (var rlock = new ReadLock(rwLock))
            {
                if (subs.ContainsKey(m.Type))
                {
                    typeSubs = subs[m.Type];
                }
            }

            if (typeSubs != null)
            {
                return(typeSubs.Post(m));
            }

            return(0);
        }