Esempio n. 1
0
        public static void Identify(CodedInputStream stream)
        {
            try
            {
                var header = new BNetHeader(stream);
                var payload = new byte[header.PayloadLength];

                payload = stream.ReadRawBytes((int) header.PayloadLength);

                var packet = new BNetPacket(header, payload);
                if (header.ServiceID == 0xfe) return;

                var service = Service.GetByID(header.ServiceID);
                if (service == null) return;

                var method =
                    service.DescriptorForType.Methods.Single(
                        m => (uint) m.Options[bnet.protocol.Rpc.MethodId.Descriptor] == header.MethodID);

                var proto = service.GetRequestPrototype(method);
                var builder = proto.WeakCreateBuilderForType();

                var message =
                    builder.WeakMergeFrom(CodedInputStream.CreateInstance(packet.Payload.ToArray())).WeakBuild();
                service.CallMethod(method, null, message, (msg => { }));
            }
            catch (UninitializedMessageException e)
            {
                Console.WriteLine("Failed to parse message: {0}", e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 2
0
        public static void Identify(CodedInputStream stream)
        {
            try
            {
                var header  = new BNetHeader(stream);
                var payload = new byte[header.PayloadLength];

                payload = stream.ReadRawBytes((int)header.PayloadLength);

                var packet = new BNetPacket(header, payload);
                if (header.ServiceID == 0xfe)
                {
                    return;
                }

                var service = Service.GetByID(header.ServiceID);
                if (service == null)
                {
                    return;
                }

                var method =
                    service.DescriptorForType.Methods.Single(
                        m => (uint)m.Options[bnet.protocol.Rpc.MethodId.Descriptor] == header.MethodID);

                var proto   = service.GetRequestPrototype(method);
                var builder = proto.WeakCreateBuilderForType();

                var message =
                    builder.WeakMergeFrom(CodedInputStream.CreateInstance(packet.Payload.ToArray())).WeakBuild();
                service.CallMethod(method, null, message, (msg => { }));
            }
            catch (UninitializedMessageException e)
            {
                Console.WriteLine("Failed to parse message: {0}", e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 3
0
 public BNetPacket(BNetHeader header, byte[] payload)
 {
     this.Header = header;
     this.Payload = payload;
 }
Esempio n. 4
0
 public BNetPacket(BNetHeader header, byte[] payload)
 {
     this.Header  = header;
     this.Payload = payload;
 }