Пример #1
0
 public void AddStream(Stream newStream)
 {
     if (DataStream == null)
     {
         DataStream = new RecordTakingOutputStream();
         DataStream.AddStream(newStream, true);
         return;
     }
     if (sendThread != null)
     {
         while (sendQueue.Count > 0)
         {
             Thread.Sleep(10);
         }
     }
     lock (receiverLock)
     {
         lock (senderLock)
         {
             try
             {
                 var uiDetach = new UIStatusHint()
                 {
                     IsDetached = true
                 };
                 var uiAttach = new UIStatusHint()
                 {
                     IsDetached = false
                 };
                 Serializer.SerializeWithLengthPrefix <GameDataPacket>(newStream, uiDetach, PrefixStyle.Base128);
                 DataStream.AddStream(newStream, true);
                 Serializer.SerializeWithLengthPrefix <GameDataPacket>(newStream, uiAttach, PrefixStyle.Base128);
                 newStream.Flush();
             }
             catch (Exception)
             {
             }
         }
     }
 }