예제 #1
0
        public ResponseMessage CreateResponseMessage(PacketPayload payload)
        {
            Throw<ArgumentNullException>.If.IsNull(payload)
                ?.Now(nameof(Payload));

            return new ResponseMessage(payload);
        }
		public NetSendResult EnqueueMessage(OperationType opType, PacketPayload payload, DeliveryMethod method, bool encrypt, byte channel, int connectionId)
		{
			outgoingMessageQueue.syncRoot.EnterWriteLock();
			try
			{
				//This is similar to how Photon works on the Unity client.
				//They enqueue actions
				outgoingMessageQueue.Enqueue(() =>
				{
					INetworkMessageRouterService sender = sendServiceStrategy.GetRouterService(connectionId);

					sender.TrySendMessage(opType, payload, method, encrypt, channel);
				});

				//signal any handlers that a message is in the queue
				//it is important to do this in a lock. Reset could be called after Set
				//in the other thread and we'd end up with potential unhandled messages in that race condition
				outgoingMessageQueue.QueueSemaphore.Set();
			}
			finally
			{
				outgoingMessageQueue.syncRoot.ExitWriteLock();
			}

			return NetSendResult.Queued;
		}
예제 #3
0
		/// <summary>
		/// Constructor for <see cref="RequestMessage"/> that calls <see cref="NetworkMessage"/>.ctor
		/// </summary>
		/// <param name="payload"><see cref="PacketPayload"/> of the <see cref="NetworkMessage"/>.</param>
		public RequestMessage(PacketPayload payload)
			: base(payload)
		{
			//TODO: Exception for null packet
		}
			public TestSerialization(PacketPayload payload)
			{
				netsendable = new NetSendable<PacketPayload>(payload);
			}
예제 #5
0
 /// <summary>
 /// Constructor for <see cref="ResponseMessage"/> that calls <see cref="NetworkMessage"/>.ctor
 /// </summary>
 /// <param name="payload"><see cref="PacketPayload"/> of the <see cref="NetworkMessage"/>.</param>
 public ResponseMessage(PacketPayload payload)
     : base(payload)
 {
     Throw<ArgumentNullException>.If.IsNull(payload)
         ?.Now(nameof(payload), $"Payload for {this.GetType().Name} must not be null in construction.");
 }
예제 #6
0
 /// <summary>
 /// Constructor for <see cref="EventMessage"/> that calls <see cref="NetworkMessage"/>.ctor
 /// </summary>
 /// <param name="payload"><see cref="PacketPayload"/> of the <see cref="NetworkMessage"/>.</param>
 public EventMessage(PacketPayload payload)
     : base(payload)
 {
     //TODO: Add exception for null packet.
 }