Ejemplo n.º 1
0
        public override void Handle(ApplicationProtocolRequest request)
        {
            EnsureMagic();

            ApplicationProtocolResponse response;

            if (!request.ProtocolName().Equals(_supportedApplicationProtocol.identifier().canonicalName()))
            {
                response = ApplicationProtocolResponse.NoProtocol;
                _channel.writeAndFlush(response);
                Decline(string.Format("Requested protocol {0} not supported", request.ProtocolName()));
            }
            else
            {
                Optional <Protocol_ApplicationProtocol> selected = _applicationProtocolRepository.select(request.ProtocolName(), SupportedVersionsFor(request));

                if (selected.Present)
                {
                    Protocol_ApplicationProtocol selectedProtocol = selected.get();
                    _protocolStackBuilder.application(selectedProtocol);
                    response = new ApplicationProtocolResponse(SUCCESS, selectedProtocol.category(), selectedProtocol.implementation());
                    _channel.writeAndFlush(response);
                }
                else
                {
                    response = ApplicationProtocolResponse.NoProtocol;
                    _channel.writeAndFlush(response);
                    Decline(string.Format("Do not support requested protocol {0} versions {1}", request.ProtocolName(), request.Versions()));
                }
            }
        }
Ejemplo n.º 2
0
 private ISet <int> SupportedVersionsFor(ApplicationProtocolRequest request)
 {
     return(_supportedApplicationProtocol.mutuallySupportedVersionsFor(request.Versions()));
 }