Exemplo n.º 1
0
 public ServerCore()
 {
     _anons          = new ConcurrentDictionary <string, ClientEntry>();
     _users          = new ConcurrentDictionary <string, ClientEntry>();
     _listner        = new ServerListner();
     _messageHandler = new MessageHandlerChain(this);
 }
Exemplo n.º 2
0
        public void SubscribeObject <T>(Action <T> action, Predicate <T> subscriberFilter, SynchronizationContext synchronizationContext)
        {
            MessageHandlerChain chain             = new MessageHandlerChain();
            IMessageSelector    messageSelector   = new PayloadTypeSelector(typeof(T));
            IMessageSelector    predecateSelector = new PredicateSelector <T>(subscriberFilter);

            ActionHandler <T> actionHandler = new ActionHandler <T>(action, synchronizationContext);

            IList <IMessageHandler> handlerList = new List <IMessageHandler>();

            handlerList.Add(new MessageFilter(messageSelector));
            handlerList.Add(new MessageFilter(predecateSelector));
            handlerList.Add(actionHandler);
            chain.Handlers = handlerList;

            Subscribe(chain);
        }
Exemplo n.º 3
0
        public void SubscribeObject <T>(object subscriber, Predicate <T> subscriberFilter, SynchronizationContext synchronizationContext)
        {
            MessageHandlerChain chain             = new MessageHandlerChain();
            IMessageSelector    messageSelector   = new PayloadTypeSelector(typeof(T));
            IMessageSelector    predecateSelector = new PredicateSelector <T>(subscriberFilter);

            UIServiceActivatingHandler serviceActivatingHandler = new UIServiceActivatingHandler(subscriber, "Receive", synchronizationContext);

            IList <IMessageHandler> handlerList = new List <IMessageHandler>();

            handlerList.Add(new MessageFilter(messageSelector));
            handlerList.Add(new MessageFilter(predecateSelector));
            handlerList.Add(serviceActivatingHandler);
            chain.Handlers = handlerList;

            Subscribe(chain);
        }