Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<Object> out) throws ClientHandshakeException
        protected internal override void Decode(ChannelHandlerContext ctx, ByteBuf @in, IList <object> @out)
        {
            int messageCode = @in.readInt();

            switch (messageCode)
            {
            case InitialMagicMessage.MESSAGE_CODE:
            {
                string magic = StringMarshal.unmarshal(@in);
                @out.Add(new InitialMagicMessage(magic));
                return;
            }

            case 0:
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                ApplicationProtocolResponse applicationProtocolResponse = DecodeProtocolResponse(ApplicationProtocolResponse::new, ByteBuf.readInt, @in);

                @out.Add(applicationProtocolResponse);
                return;
            }

            case 1:
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                ModifierProtocolResponse modifierProtocolResponse = DecodeProtocolResponse(ModifierProtocolResponse::new, StringMarshal.unmarshal, @in);

                @out.Add(modifierProtocolResponse);
                return;
            }

            case 2:
            {
                int statusCodeValue = @in.readInt();
                Optional <StatusCode> statusCode = StatusCode.fromCodeValue(statusCodeValue);
                if (statusCode.Present)
                {
                    @out.Add(new SwitchOverResponse(statusCode.get()));
                }
                else
                {
                    // TODO
                }
                return;
            }

            default:
                // TODO
                return;
            }
        }
Exemplo n.º 2
0
        public override void Handle(ModifierProtocolResponse modifierProtocolResponse)
        {
            EnsureMagic();
            if (modifierProtocolResponse.StatusCode() == StatusCode.Success)
            {
                Optional <Protocol_ModifierProtocol> selectedModifierProtocol = _modifierProtocolRepository.select(modifierProtocolResponse.ProtocolName(), modifierProtocolResponse.Version());
                _negotiatedModifierProtocols.Add(Pair.of(modifierProtocolResponse.ProtocolName(), selectedModifierProtocol));
            }
            else
            {
                _negotiatedModifierProtocols.Add(Pair.of(modifierProtocolResponse.ProtocolName(), null));
            }

            SendSwitchOverRequestIfReady();
        }
Exemplo n.º 3
0
        public override void Handle(ModifierProtocolRequest modifierProtocolRequest)
        {
            EnsureMagic();

            ModifierProtocolResponse             response;
            Optional <Protocol_ModifierProtocol> selected = _modifierProtocolRepository.select(modifierProtocolRequest.ProtocolName(), SupportedVersionsFor(modifierProtocolRequest));

            if (selected.Present)
            {
                Protocol_ModifierProtocol modifierProtocol = selected.get();
                _protocolStackBuilder.modifier(modifierProtocol);
                response = new ModifierProtocolResponse(SUCCESS, modifierProtocol.category(), modifierProtocol.implementation());
            }
            else
            {
                response = ModifierProtocolResponse.Failure(modifierProtocolRequest.ProtocolName());
            }

            _channel.writeAndFlush(response);
        }
Exemplo n.º 4
0
 public override void Handle(ModifierProtocolResponse modifierProtocolResponse)
 {
     Out.writeInt(1);
     EncodeProtocolResponse(modifierProtocolResponse, StringMarshal.marshal);
 }