コード例 #1
0
        public void Test222()
        {
            try
            {
                try
                {
                    File.Delete(PacketBufferHelper.GetBufferDbPath());
                }
                catch { }


                var buffer = new RealmPacketBuffer();


                var list = new List <byte[]>()
                {
                    "120808020B002F".ToByteArray(),
                };

                object message = null;

                foreach (var bytes in list)
                {
                    message = Message.Unpack(bytes, buffer);
                }
            }
            catch (Exception e)
            {
                Debugger.Break();
            }
        }
コード例 #2
0
        public void Location__()
        {
            try
            {
                try
                {
                    File.Delete(PacketBufferHelper.GetBufferDbPath());
                }
                catch { }


                var    buffer = new RealmPacketBuffer();
                string text   = @"Shovel works with all types of exchanges. 
In this example, I've set up exchanges as direct exchanges which use routing keys. 
However, if you have fanout exchanges, those will work as well—but you won't indicate a routing key when setting up the shovel for the exchange.
To demonstarate how you can send messages, let's look at the shovels we created for the first exchange that we set up—compose-to-messages-rmq. 
This shovel connects to our Compose for RabbitMQ exchange compose-exchange with our messages-rmq exchange in our Messages for RabbitMQ instance. 
Ive also created two queues to send messages to: compose - queue in the Compose instance and messages - queue in the Messages for RabbitMQ instance. 
Since the shovel is sending messages to the two exchanges, the queues have been bound to the exchanges so that the messages are received and queued up.";

                var __a = ChatMessageMT.Create(ProtocolVersion.v3__WeatherExtension, Subscriber.Create("*****@*****.**", SubscriberNetwork.Email), null, null, text);
                var __b = ChatMessageMO.Create(ProtocolVersion.v3__WeatherExtension, Subscriber.Create("79153925491", SubscriberNetwork.Mobile), null, null, text);

                var a = __a.Pack(56);
                var b = __b.Pack(56);

                var totalLength = a.Select(x => x.Payload.Length - 8).Sum();

                var m1_ = MessageMO.Unpack(b[1].Payload, buffer) as ChatMessageMO;
                var m2  = MessageMT.Unpack(a[1].Payload, buffer) as ChatMessageMT;
                var m1  = MessageMT.Unpack(a[0].Payload, buffer) as ChatMessageMT;
                var m2_ = MessageMO.Unpack(b[0].Payload, buffer) as ChatMessageMO;
                var m3  = MessageMT.Unpack(a[2].Payload, buffer) as ChatMessageMT;
                var m3_ = MessageMO.Unpack(b[2].Payload, buffer) as ChatMessageMO;

                if (!m3.Complete)
                {
                    throw new Exception();
                }

                if (m3.Text != text)
                {
                    throw new Exception();
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #3
0
        public void FileTest()
        {
            try
            {
                File.Delete(PacketBufferHelper.GetBufferDbPath());
            }
            catch { }

            try
            {
                var file = File.OpenRead(@"C:\Users\Banana\Desktop\file.txt");
                var m    = ChatMessageMT.Create(
                    ProtocolVersion.v3__WeatherExtension,
                    new Subscriber("79999740562", SubscriberNetwork.Mobile), null, null,
                    "hello image",
                    lat: 12,
                    lon: -56,
                    alt: 561,
                    file: file,
                    fileExtension: FileExtension.Jpg,
                    imageQuality: ImageQuality.Low);

                var packets = m.Pack();

                string s = packets[0].Payload.ToHexString();

                var           buffer  = new RealmPacketBuffer();
                ChatMessageMT message = null;

                foreach (var p in packets)
                {
                    message = Message.Unpack(p.Payload, buffer) as ChatMessageMT;
                }

                if (m.File.Length != message.File.Length)
                {
                    Assert.Fail();
                }

                var bytes = (message.File as MemoryStream).GetBuffer();
                File.WriteAllBytes(@"/Users/banana/Downloads/rockstar-media-test[unpacked].jpg", bytes);
            }
            catch (Exception e)
            {
            }
        }