Home Forums Support Closed/closing connection strategy Reply To: Closed/closing connection strategy


Would it be possible for TCPConnection.GetConnection to tell me if it returned a new connection so that I can set the handlers on that connection as well?

No, but you could check each connection before it is used to ensure that the necessary packet handlers exist, if not add them:

Connection conn = TCPConnection.GetConnection();

if (!conn.IncomingPacketHandlerExists("data", packetHandler))
    conn.AppendIncomingPacketHandler("data", packetHandler);

A question though, why not just set global packet handlers on the clientside:

NetworkComms.AppendGlobalIncomingPacketHandler("data", packetHandler);

Then you don’t have to worry about connection specific packet handlers.