Ejemplo n.º 1
0
 public void VerifyByteAppedingToMessage_AppendByte128BytesAtATime()
 {
     var msgData = Log.SerializeLog(CreateLog());
     var data = Message.CreateMessageByte(msgData, MessageTypes.SendLog);
     var msg = new Message();
     var status = -3;
     var step = 128;
     for (int i = 0; i < data.Length; i += step)
     {
         byte[] buffer = null;
         if ((i + step) < data.Length)
         {
             buffer = new byte[step];
             Buffer.BlockCopy(data, i, buffer, 0, step);
         }
         else
         {
             step = data.Length - i;
             buffer = new byte[step];
             Buffer.BlockCopy(data, i, buffer, 0, step);
         }
         status = msg.AppendData(buffer, buffer.Length, 0);
     }
     Assert.That(msg.Type, Is.EqualTo(MessageTypes.SendLog));
     Assert.That(msg.Data, Is.EquivalentTo(msgData));
     Assert.That(status, Is.EqualTo(step));
 }
 private static void ProcessMessage(Message msg, AsyncManager asyncMgr)
 {
     switch (msg.Type)
     {
         case MessageTypes.Results:
             ProcessResults(msg, asyncMgr);
             break;
     }
     asyncMgr.OutstandingOperations.Decrement();
 }
Ejemplo n.º 3
0
 public void VerifyByteAppedingToMessage_AppendByteAtOnce()
 {
     var msgData = Log.SerializeLog(CreateLog());
     var data = Message.CreateMessageByte(msgData, MessageTypes.SendLog);
     var msg = new Message();
     var status = msg.AppendData(data, data.Length, 0);
     Assert.That(msg.Type, Is.EqualTo(MessageTypes.SendLog));
     Assert.That(msg.Data, Is.EquivalentTo(msgData));
     Assert.That(status, Is.EqualTo(data.Length));
 }
 public static void OnMessageArrived(Message msg)
 {
     if (msg.MessageBag != null)
     {
         var asyncMgr = msg.MessageBag as AsyncManager;
         if (asyncMgr != null)
         {
             ProcessMessage(msg, asyncMgr);
         }
     }
 }
Ejemplo n.º 5
0
 public void VerifyByteAppedingToMessage_AppendByteOneAtATime()
 {
     var msgData = Log.SerializeLog(CreateLog());
     var data = Message.CreateMessageByte(msgData, MessageTypes.SendLog);
     var msg = new Message();
     var status = -3;
     for (int i = 0; i < data.Length; i++)
     {
         status = msg.AppendData(new byte[] { data[i] }, 1, 0);
     }
     Assert.That(msg.Type, Is.EqualTo(MessageTypes.SendLog));
     Assert.That(msg.Data, Is.EquivalentTo(msgData));
     Assert.That(status, Is.EqualTo(1));
 }
Ejemplo n.º 6
0
 public void Clear()
 {
     this.msg = new Message();
 }
Ejemplo n.º 7
0
 public ClientStateObject(Action<Message> onMessageReceived)
 {
     this.buffer = new byte[MaxBufferSize];
     this.msg = new Message();
     this.onMessageReceived = onMessageReceived;
 }
 private void OnMessageArrivedNull(Message msg)
 {
     //Empty Method to Disregard Messages if onMessageArrived is Not set.
 }
 private static void ProcessResults(Message msg, AsyncManager asyncMgr)
 {
     var results = LogQueryResults.DeserializeLog(msg.Data);
     asyncMgr.Parameters["details"] = results.LogIDs;
 }
 private void OnMessageArrivedSocketHandler(Message msg)
 {
     if (messageTracker.ContainsKey(msg.MessageGuid))
     {
         MessageTrackingObject msgTrack = null;
         if (messageTracker.TryRemove(msg.MessageGuid, out msgTrack))
         {
             msg.MessageBag = msgTrack.MessageBag;
         }
     }
     clientMessageArrviedHandler(msg);
 }
Ejemplo n.º 11
0
 public void Clear()
 {
     this.Status = ReceiveStatuses.Receiving;
     this.msg = new Message();
 }
Ejemplo n.º 12
0
 public ReceiveStateObject()
 {
     this.buffer = new byte[MaxBufferSize];
     this.Status = ReceiveStatuses.Receiving;
     this.msg = new Message();
 }