Exemple #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()));
                }
            }
        }
Exemple #2
0
        private void SendSwitchOverRequestIfReady()
        {
            if (_negotiatedApplicationProtocol != null && _negotiatedModifierProtocols.Count == _supportedModifierProtocols.Count)
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
                IList <Protocol_ModifierProtocol> agreedModifierProtocols = _negotiatedModifierProtocols.Select(Pair::other).flatMap(Streams.ofOptional).ToList();

                _protocolStack = new ProtocolStack(_negotiatedApplicationProtocol, agreedModifierProtocols);
                IList <Pair <string, string> > switchOverModifierProtocols = agreedModifierProtocols.Select(protocol => Pair.of(protocol.category(), protocol.implementation())).ToList();

                _channel.writeAndFlush(new SwitchOverRequest(_negotiatedApplicationProtocol.category(), _negotiatedApplicationProtocol.implementation(), switchOverModifierProtocols));
            }
        }