public void create_should_return_protocol_handler()
        {
            var protocolHandler = Substitute.For <IProtocolHandler>();
            var session         = Substitute.For <ISession>();

            _subprotocolFactory.Create(session).Returns(protocolHandler);
            var handler = _factory.Create(session);

            _subprotocolFactory.Received().Create(session);
            handler.Should().Be(protocolHandler);
        }
Beispiel #2
0
        public void Connect()
        {
            CheckAuthenticated();
            CheckNotConnected();

            protocolHandler            = protocolHandlerFactory.Create();
            protocolHandler.Dispatcher = messageBroker;
            protocolHandler.Connect(config.GameServerAddress, sessionId, sessionCookie);

            this.state = GameClientState.Connected;
        }
Beispiel #3
0
        public void Init()
        {
            if (_logger.IsTrace)
            {
                _logger.Trace("Initializing NDM capability connector.");
            }
            _accountService.AddressChanged += (_, e) =>
            {
                if (e.OldAddress == e.NewAddress)
                {
                    return;
                }

                if (!(e.OldAddress is null) && e.OldAddress != Address.Zero)
                {
                    return;
                }

                AddCapability();
            };
            _protocolsManager.AddProtocol(Protocol.Ndm, session => _protocolHandlerFactory.Create(session));
            var consumerAddress = _accountService.GetAddress();

            if ((consumerAddress is null || consumerAddress == Address.Zero) &&
                (_providerAddress is null || _providerAddress == Address.Zero))
            {
                return;
            }

            _protocolsManager.AddSupportedCapability(Capability);
            _protocolsManager.P2PProtocolInitialized += (sender, args) => { TryAddCapability(); };
            if (_logger.IsTrace)
            {
                _logger.Trace("Initialized NDM capability connector.");
            }
        }
        public void DispatchRequest(String requestType)
        {
            IProtocolHandler handler = _factory.Create(requestType);

            handler.Process();
        }