예제 #1
0
        public bool AddChannelHandle(string id, MarketMessageType type, IUserChannelNotification channel)
        {
            CommandKey key = new CommandKey(type, id);

            bool firstHandle = false;

            if (!messageListeners.TryGetValue(key, out IEnumerable <IUserChannelNotification> list))
            {
                list = new ConcurrentBag <IUserChannelNotification>();
                messageListeners.TryAdd(key, list);

                firstHandle = true;
            }
            else
            {
                if (bookCache.TryGetValue(id, out BookMessageCache cache))
                {
                    channel.Arrived(cache.Snapshot());
                }
            }

            if (!list.Contains(channel))
            {
                ((ConcurrentBag <IUserChannelNotification>)list).Add(channel);
            }

            return(firstHandle);
        }
예제 #2
0
        public CommandKey(MarketMessageType type, string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentException("'id' is not null");
            }

            this.type = type;
            this.id   = id;
        }
예제 #3
0
        public bool RemoveChannelHandle(string id, MarketMessageType type, IUserChannelNotification channel)
        {
            CommandKey key = new CommandKey(type, id);

            if (messageListeners.TryGetValue(key, out IEnumerable <IUserChannelNotification> list))
            {
                var tmp = list.ToList();
                tmp.Remove(channel);

                if (!tmp.Any())
                {
                    messageListeners.Remove(key, out list);

                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
 public MessageSerialize(MarketMessageType type) : base(type)
 {
 }
예제 #5
0
 public MessageBase(MarketMessageType type)
 {
     this.type = type;
 }
예제 #6
0
 public bool AllocatePostmanThread(string symbol, MarketMessageType type)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public void AddChannelHandle(string v, MarketMessageType mINI_BOOK, Func <object> p)
 {
     throw new NotImplementedException();
 }