/// Called when an incoming message is received public override void MessageReceived(NetClientBase client_in, BaseMessage msg_in) { Console.WriteLine($"App: Received: from {client_in.GetNicePeerAddr()} '{msg_in.ToString()}'"); switch (msg_in.GetType()) { case MessageType.Handshake: { HandshakeMessage hsMsg = msg_in as HandshakeMessage; //cout << "Handshake message received, '" << hsMsg.getMyAddr() << "'" << endl; if (hsMsg.GetMyVersion() != "V01") { Console.Error.WriteLine($"Wrong version '{hsMsg.GetMyVersion()}'"); client_in.Close(); return; } HandshakeResponseMessage resp = new HandshakeResponseMessage("V01", myName, client_in.GetPeerAddr()); client_in.SendMessage(resp); } break; case MessageType.Ping: { PingMessage pingMsg = msg_in as PingMessage; //cout << "Ping message received, '" << pingMsg.GetText() << "'" << endl; PingResponseMessage resp = new PingResponseMessage("Resp_from_" + myName + "_to_" + pingMsg.GetText()); client_in.SendMessage(resp); } break; default: System.Diagnostics.Debug.Assert(false); break; } }