Home Forums Support new TCPConnection WITHOUT being reused Reply To: new TCPConnection WITHOUT being reused

#4049
Anonymous
Inactive

On the server, instead of using “Reply” as the return packet type, why not use “Reply.1” and “Reply.2”? Then configure the client to use these types as the expected return.

What you want to achieve it very easy to do in NetworkComms.Net, you are just missing the tremendous flexibility offered by named packet types.

On the server:


//Handle incoming packet type "Message.1"
private void ProcessRequestReply<T>(PacketHeader packetHeader, Connection connection, T inputObject)
{
      BasicRequest input = null;
      input = inputObject as BasicRequest;
 
      string errorText = String.Format("!!!dummy error|{0}|{1}", -100, "Error Message with reason");
      connection.SendObject("Reply.1", new BasicReply(input.MessageId, errorText));
}

//Handle incoming packet type "Message.2"
private void ProcessRequestReply<T>(PacketHeader packetHeader, Connection connection, T inputObject)
{
      BasicRequest input = null;
      input = inputObject as BasicRequest;
 
      string errorText = String.Format("!!!dummy error|{0}|{1}", -100, "Error Message with reason");
      connection.SendObject("Reply.2", new BasicReply(input.MessageId, errorText));
}

On the client:


//Send "Message.1" and expect "Reply.1" back.
connection.SendReceiveObject<String>("Message.1", "Reply.1", 1000);

//Send "Message.2" and expect "Reply.2" back.
connection.SendReceiveObject<String>("Message.2", "Reply.2", 1000);

This methodology is demonstrated in the AdvancedSend.cs example.