Example #1
0
        public Result Subscribe(object o, uint msgType, Action <Msg> action)
        {
            using (var wlock = new WriteLock(rwLock))
            {
                if (subs.ContainsKey(msgType))
                {
                    var typeSubs = subs[msgType];

                    return(typeSubs.Subscribe(
                               new Sub
                    {
                        Owner = o,
                        MsgType = msgType,
                        Action = action
                    }));
                }
                else
                {
                    var typeSubs = new TypeSubs(msgType);
                    subs[msgType] = typeSubs;

                    return(typeSubs.Subscribe(
                               new Sub
                    {
                        Owner = o,
                        MsgType = msgType,
                        Action = action
                    }));
                }
            }
        }
Example #2
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);
        }