コード例 #1
0
        public void TestPacket()
        {
            var a = new BridgeStream();

            a.Write("Ferhat");
            a.Write(10);
            a.Write(true);
            a.Write((byte)255);
            a.Write(15f);
            _sendBridgeStream.Write(a);

            var b = new BridgeStream();

            b.Write("Mehmet");
            b.Write(15);
            b.Write(35f);
            _sendBridgeStream.Write(b);

            var data = _sendBridgeStream.Encode();

            var receivePacket = new BridgeStream(data);
            var readPacketA   = receivePacket.ReadStream();
            var readPacketB   = receivePacket.ReadStream();

            Assert.AreEqual("Ferhat", readPacketA.ReadString(),
                            "Expected to get the same string as the first read on the received packet");
            Assert.AreEqual(10, readPacketA.ReadInt(),
                            "Expected to get the same integer as the second read on the received packet");
            Assert.AreEqual(true, readPacketA.ReadBool(),
                            "Expected to get the same bool as the second read on the received packet");
            Assert.AreEqual((byte)255, readPacketA.ReadByte(),
                            "Expected to get the same byte as the third read on the received packet");
            Assert.AreEqual("Mehmet", readPacketB.ReadString(),
                            "Expected to get the same string as the first read on the received packet");
            Assert.AreEqual(15, readPacketB.ReadInt(),
                            "Expected to get the same integer as the second read on the received packet");
            Assert.AreEqual(35f, readPacketB.ReadFloat(),
                            "Expected to get the same float as the third read on the received packet");
        }
コード例 #2
0
        public void TestInt()
        {
            _sendBridgeStream.Write(10);
            var data          = _sendBridgeStream.Encode();
            var receivePacket = new BridgeStream(data);
            var sendValue     = receivePacket.ReadInt();

            Assert.AreEqual(10, sendValue);
        }
コード例 #3
0
 public void Write(BridgeStream stream)
 {
     stream.Write(matchId);
     stream.Write(playerIds);
     stream.Write(playerNames);
 }