void ProcessServerMessage(string mes) { string[] vs = mes.Contains(',') ? mes.Split(',') : new string[] { mes }; switch (vs[0]) { case "End": DebugLogging("Server Shutdown"); ShutDownClient(); break; case "Kicked": DebugLogging("Kicked From Server"); ShutDownClient(); break; case "Assign": NetworkInitialize(byte.Parse(vs[1])); break; case "CList": UpdateClientList(vs); break; case "RPC": ProcessRemoteProcedureCall(vs[1], encoding.GetBytes(mes.Substring(5 + vs[1].Length))); break; default: OnTcpMessageReceived?.Invoke(encoding.GetBytes(mes)); break; } }
void ClientRequest(string request, ClientDataContainer_ForTool client) { string[] vs = request.Contains(',') ? request.Split(',') : new string[] { request }; switch (vs[0]) { case "Init": SendInitialMessage(client, vs[1], int.Parse(vs[2])); break; case "Disconnect": ClientDisconnected(client); break; case "RPC": ProcessRemoteProcedureCall(client, vs[1], (NetworkEventType)Enum.ToObject(typeof(NetworkEventType), int.Parse(vs[2])), encoding.GetBytes(request.Substring(7 + vs[1].Length))); break; default: OnTcpMessageReceived?.Invoke(encoding.GetBytes(request), client); break; } }