Example #1
0
        public bool FlushNextMessage(TestYInstance sender, TestYInstance receiver)
        {
            Assert.AreNotEqual(sender, receiver);

            var messages = receiver._receiving[sender];

            if (messages.Count == 0)
            {
                receiver._receiving.Remove(sender);
                return(false);
            }

            var m = messages.Dequeue();

            // Debug.WriteLine($"MSG {sender.ClientId} -> {receiver.ClientId}, len {m.Length}:");
            // Debug.WriteLine(string.Join(",", m));

            using var writer = new MemoryStream();
            using (var reader = new MemoryStream(m))
            {
                SyncProtocol.ReadSyncMessage(reader, writer, receiver, receiver._tc);
            }

            if (writer.Length > 0)
            {
                // Send reply message.
                var replyMessage = writer.ToArray();
                // Debug.WriteLine($"REPLY {receiver.ClientId} -> {sender.ClientId}, len {replyMessage.Length}:");
                // Debug.WriteLine(string.Join(",", replyMessage));
                sender.Receive(replyMessage, receiver);
            }

            return(true);
        }
Example #2
0
        public void Receive(byte[] data, TestYInstance remoteDoc)
        {
            if (!_receiving.TryGetValue(remoteDoc, out var messages))
            {
                messages = new Queue <byte[]>();
                _receiving[remoteDoc] = messages;
            }

            messages.Enqueue(data);
        }
Example #3
0
 private void BroadcastMessage(TestYInstance sender, byte[] data)
 {
     if (_tc._onlineConns.Contains(sender))
     {
         foreach (var conn in _tc._onlineConns)
         {
             if (sender != conn)
             {
                 conn.Receive(data, sender);
             }
         }
     }
 }
Example #4
0
 protected void CompareUsers(TestYInstance left, TestYInstance right)
 {
 }