Exemple #1
0
 public void SendEnd(EndData se)
 {
     if (!started || Learning)
     {
         return;
     }
     Learning           = true;
     WaitingSkillLevels = true;
     Debug.Log("Round++,Now:" + RoundNow);
     //sts = se;
     Src[Sender.clientNum]  = se;
     SLtb[Sender.clientNum] = true;
     Debug.Log("End Message " + Sender.clientNum + " Set");
     Bond.IO.Safe.OutputBuffer ob2 = new Bond.IO.Safe.OutputBuffer(128);
     Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer> boc = new Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer>(ob2);
     Serialize.To(boc, se);
     byte[] sendBytes = new byte[ob2.Data.Array.Length + 1];
     sendBytes[0] = (byte)2;
     ob2.Data.Array.CopyTo(sendBytes, 1);
     foreach (CSteamID i in TOmb)
     {
         if (i != SteamUser.GetSteamID())
         {
             SteamNetworking.SendP2PPacket(i, sendBytes, (uint)sendBytes.Length, EP2PSend.k_EP2PSendReliable);
         }
     }
     Debug.Log("End Sent");
     EndingCompare();
     TotalRounds = int.Parse(SteamMatchmaking.GetLobbyData(Sender.roomid, "Total_Rounds"));
     LearnTime   = int.Parse(SteamMatchmaking.GetLobbyData(Sender.roomid, "Learn_Time"));
 }
Exemple #2
0
 private void Update()
 {
     if (!isstarted)
     {
         return;
     }
     if ((LocalFrameNum - PassedFrameNum) < 5)
     {
         if (!RToggle.isOn)
         {
             RToggle.isOn = true;
         }
         LocalCurrentLength += Time.unscaledDeltaTime;
     }
     else
     {
         RToggle.isOn        = false;
         LocalCurrentLength += Time.unscaledDeltaTime / 4;
     }
     while (LocalCurrentLength >= LocalFrameLength)
     {
         Data2S Fd2s = new Data2S();
         Fd2s.frameNum   = LocalFrameNum;
         Fd2s.clientNum  = Sender.clientNum;
         Fd2s.clickDatas = L2S;
         Bond.IO.Safe.OutputBuffer ob = new Bond.IO.Safe.OutputBuffer(64);
         Bond.Protocols.FastBinaryWriter <Bond.IO.Safe.OutputBuffer> bof = new Bond.Protocols.FastBinaryWriter <Bond.IO.Safe.OutputBuffer>(ob);
         Serialize.To(bof, Fd2s);
         ///NetworkTransport.Send(Sender.HSID, Sender.CNID, channelID, ob.Data.Array, ob.Data.Array.Length, out error);
         byte[] sendBytes = new byte[ob.Data.Array.Length + 1];
         sendBytes[0] = (byte)0;
         ob.Data.Array.CopyTo(sendBytes, 1);
         for (int i = 0; i < Sender.TOmb.Length; i++)
         {
             if (i != Sender.clientNum)
             {
                 SteamNetworking.SendP2PPacket(Sender.TOmb[i], sendBytes, (uint)sendBytes.Length, EP2PSend.k_EP2PSendReliable);
             }
         }
         int a = LocalFrameNum - PassedFrameNum - 1;
         theLL.addat(a, Sender.clientNum, L2S);
         //Debug.Log("吃!");
         if (Sender.isTesting)
         {
             theLL.addat(a, 1, L2S);
         }
         if (Time.timeScale < 0.6 && theLL.Numready(3))
         {
             //isstarted = false;
             Time.timeScale = 1;
             Debug.Log("TimeScale set to 1 by Update");
         }
         //
         L2S.Clear();
         //buffer2s = new byte[1024];
         LocalCurrentLength -= LocalFrameLength;
         //Debug.Log("Wey: " + LocalFrameNum);
         LocalFrameNum++;
     }
 }
Exemple #3
0
    public void SendMyWord()
    {
        Bond.IO.Safe.OutputBuffer outputBuffer = new Bond.IO.Safe.OutputBuffer(4096);
        Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer> compactBinaryWriter = new Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer>(outputBuffer);
        UserWord userWord = new UserWord();

        userWord.myWord = MyWord.text;
        MyWord.text     = "";
        Serialize.To(compactBinaryWriter, userWord);
        SteamMatchmaking.SendLobbyChatMsg(Sender.roomid, outputBuffer.Data.Array, outputBuffer.Data.Array.Length);
    }
Exemple #4
0
 public void Sendlsd(SkillData sd)
 {
     Bond.IO.Safe.OutputBuffer ob2 = new Bond.IO.Safe.OutputBuffer(128);
     Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer> boc = new Bond.Protocols.CompactBinaryWriter <Bond.IO.Safe.OutputBuffer>(ob2);
     Serialize.To(boc, sd);
     byte[] sendBytes = new byte[ob2.Data.Array.Length + 1];
     sendBytes[0] = (byte)1;
     ob2.Data.Array.CopyTo(sendBytes, 1);
     for (int i = 0; i < TOmb.Length; i++)
     {
         if (i != clientNum)
         {
             SteamNetworking.SendP2PPacket(TOmb[i], sendBytes, (uint)sendBytes.Length, EP2PSend.k_EP2PSendReliable);
         }
     }
 }
Exemple #5
0
        public void SimpleBinaryReader_ReadLength_NegativeLength_Throws()
        {
            var f = new Foo {
                _str = "abc"
            };
            var output = new Bond.IO.Safe.OutputBuffer(16);
            var writer = new SimpleBinaryWriter <OutputBuffer>(output, 2);

            Serialize.To(writer, f);


            var data = new byte[]
            {
                0x00,

                0xff, // count (5 byte)
                0xff,
                0xff,
                0xff,
                0xff,

                0x00,
                0x00,
                0x00,
                0x61,
            };

            var input  = new InputBuffer(data);
            var reader = new SimpleBinaryReader <InputBuffer>(input);

            Assert.Throws <OverflowException>(() => Deserialize <Foo> .From(reader));

            input  = new InputBuffer(data);
            reader = new SimpleBinaryReader <InputBuffer>(input, 2);
            Assert.Throws <OverflowException>(() => Deserialize <Foo> .From(reader));
        }
        public static void CreateFrames()
        {
            // Set up the non-empty layer data we'll use.
            Bond.IBonded goodLayerObject = new Bond.Bonded<Dummy>(dummyObject);
            var outputBuffer = new OutputBuffer();
            var compactWriter = new CompactBinaryWriter<OutputBuffer>(outputBuffer);
            compactWriter.WriteVersion();
            goodLayerObject.Serialize(compactWriter);
            goodLayerData = outputBuffer.Data;

            // Good frames, from which we can pull good framelets to build bad frames.
            goodRequestFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.REQUEST, meaninglessPayload, null, LoggerTests.BlackHole);
            goodRequestLayerDataFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.REQUEST, meaninglessPayload, goodLayerObject, LoggerTests.BlackHole);

            goodResponseFrame = EpoxyConnection.MessageToFrame(
                GoodResponseId, GoodService, GoodMethod, EpoxyMessageType.RESPONSE, meaninglessPayload, null, LoggerTests.BlackHole);
            goodErrorResponseFrame = EpoxyConnection.MessageToFrame(
                GoodResponseId, GoodService, GoodMethod, EpoxyMessageType.RESPONSE, meaninglessError, null, LoggerTests.BlackHole);

            goodEventFrame = EpoxyConnection.MessageToFrame(
                GoodRequestId, GoodService, GoodMethod, EpoxyMessageType.EVENT, meaninglessPayload, null, LoggerTests.BlackHole);

            configFrame = EpoxyConnection.MakeConfigFrame(LoggerTests.BlackHole);
            protocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(MeaninglessErrorCode, null, LoggerTests.BlackHole);

            var goodFrameletCount = goodRequestFrame.Count;

            // Bad frames made of good framelets.
            shortRequestFrame = new Frame(goodFrameletCount - 1, LoggerTests.BlackHole);
            for (var i = 0; i < goodFrameletCount - 1; i++)
            {
                shortRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }

            doubleHeadersRequestFrame = new Frame(goodFrameletCount + 1, LoggerTests.BlackHole);
            doubleHeadersRequestFrame.Add(goodRequestFrame.Framelets[0]);
            for (var i = 0; i < goodFrameletCount; i++)
            {
                doubleHeadersRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }

            headersConfigRequestFrame = new Frame(2, LoggerTests.BlackHole);
            headersConfigRequestFrame.Add(goodRequestFrame.Framelets[0]);
            headersConfigRequestFrame.Add(configFrame.Framelets[0]);

            doublePayloadRequestFrame = new Frame(goodFrameletCount + 1, LoggerTests.BlackHole);
            for (var i = 0; i < goodFrameletCount; i++)
            {
                doublePayloadRequestFrame.Add(goodRequestFrame.Framelets[i]);
            }
            doublePayloadRequestFrame.Add(goodRequestFrame.Framelets[goodFrameletCount - 1]);

            backwardsRequestFrame = new Frame(goodFrameletCount, LoggerTests.BlackHole);
            foreach (var framelet in goodRequestFrame.Framelets.Reverse())
            {
                backwardsRequestFrame.Add(framelet);
            }

            doubleProtocolErrorFrame = EpoxyConnection.MakeProtocolErrorFrame(MeaninglessErrorCode, null, LoggerTests.BlackHole);
            doubleProtocolErrorFrame.Add(doubleProtocolErrorFrame.Framelets[0]);

            configFrameExtra = EpoxyConnection.MakeConfigFrame(LoggerTests.BlackHole);
            configFrameExtra.Add(goodRequestFrame.Framelets[0]);

            // Bad frames made of bad framelets.
            var invalidConfigData = new ArraySegment<byte>(new byte[] { 0x01 });
            configFrameBadConfigData = new Frame(1, LoggerTests.BlackHole);
            configFrameBadConfigData.Add(new Framelet(FrameletType.EpoxyConfig, invalidConfigData));
        }