Example #1
0
        public void Dispatch(MessageDispatch dispatch)
        {
            var queue   = GetQueue(dispatch.Message.GetType());
            var invoker = GetInvoker(dispatch.Message.GetType());

            queue.RunOrEnqueue(dispatch, invoker);
        }
Example #2
0
        public void Start()
        {
            Self = new Peer(PeerId, EndPoint);

            _directory.Configure(this);

            _transport = _container.GetInstance <ITransport>();
            _transport.Configure(PeerId, EndPoint);

            _transport.Start();

            _transport.MessageReceived += (transportMessage) =>
            {
                var message = ToMessage(transportMessage);
                var dispach = new MessageDispatch(message);
                _messageDispatcher.Dispatch(dispach);
            };

            PerformAutoSubscribe();

            Task.Delay(1000).Wait();
        }