예제 #1
0
        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 1:
            {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                ApplicationProtocolRequest applicationProtocolRequest = DecodeProtocolRequest(ApplicationProtocolRequest::new, @in, ByteBuf.readInt);
                @out.Add(applicationProtocolRequest);
                return;
            }

            case 2:
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                ModifierProtocolRequest modifierProtocolRequest = DecodeProtocolRequest(ModifierProtocolRequest::new, @in, StringMarshal.unmarshal);
                @out.Add(modifierProtocolRequest);
                return;

            case 3:
            {
                string protocolName = StringMarshal.unmarshal(@in);
                int    version      = @in.readInt();
                int    numberOfModifierProtocols = @in.readInt();
                IList <Pair <string, string> > modifierProtocols = Stream.generate(() => Pair.of(StringMarshal.unmarshal(@in), StringMarshal.unmarshal(@in))).limit(numberOfModifierProtocols).collect(Collectors.toList());
                @out.Add(new SwitchOverRequest(protocolName, version, modifierProtocols));
                return;
            }

            default:
                // TODO
                return;
            }
        }
예제 #2
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);
        }
예제 #3
0
 private ISet <string> SupportedVersionsFor(ModifierProtocolRequest request)
 {
     return(_modifierProtocolRepository.supportedProtocolFor(request.ProtocolName()).map(supported => supported.mutuallySupportedVersionsFor(request.Versions())).orElse(Collections.emptySet()));
 }
예제 #4
0
 public override void Handle(ModifierProtocolRequest modifierProtocolRequest)
 {
     Out.writeInt(2);
     EncodeProtocolRequest(modifierProtocolRequest, StringMarshal.marshal);
 }