Ejemplo n.º 1
0
        public override void WriteTo(byte[] buf, ref int i)
        {
            var stream = new BitDataOutputStream(buf, i);

            _innerMessage.WriteTo(stream);
            i = stream.i;
        }
Ejemplo n.º 2
0
 public override void SendMessage(Message message)
 {
     if (_service != null)
     {
         lock (_sendingMsgCache) {
             var copy  = Message.New(message.MessageType);
             var read  = new BitDataInputStream(_exchange);
             var write = new BitDataOutputStream(_exchange);
             message.WriteTo(write);
             copy.ReadFrom(read);
             _sendingMsgCache.Add(copy);
             Monitor.Pulse(_sendingMsgCache);
         }
     }
     else
     {
         var identifiedMsg = message as IdentifiedMessage;
         if (identifiedMsg != null)
         {
             if (_messageReceiverDict.TryGetValue(IdentifiedMessage.MESSAGE_TYPE, out List <IMessageReceiver> receivers))
             {
                 foreach (var receiver in receivers)
                 {
                     receiver.MessageReceived(new IdentifiedMessage()
                     {
                         resp = true, guid = identifiedMsg.guid, innerMessage = null
                     });
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
		public override void WriteTo(IDataOutputStream stream) {
			stream.WriteInt32(this.InnerMsgType);
			if (innerMessage != null) innerMessage.WriteTo(stream);
			OutputStreamHelper.WriteGuid(stream, guid);
			stream.WriteBoolean(resp);
		}