protected void SystemCmds(SocketUser user, Data data) { byte cmd = data.Buffer[0]; data.Buffer = BufferUtils.RemoveFront(BufferUtils.Remove.CMD, data.Buffer); switch (cmd) { case 0x02: // udp enable //Logger.Log("{0}: Udp enabled", user.SessionToken); int port = BitConverter.ToInt32(data.Buffer, 0); user.EnableUdp(port); user.Send(0xff, new byte[] { 0x02 }, Protocal.Udp); UserUdpEnabled(user); break; case 0x03: // ping bool pingBack = BitConverter.ToBoolean(data.Buffer, 0); if (pingBack) { user.Send(0xff, BufferUtils.AddFirst(0x03, BitConverter.GetBytes(false)), data.Type); } UserPinged(user, data.Type, pingBack); break; default: Logger.LogError("Received invalid system command: {0}", cmd); break; } }
public void Identify_CMD(SocketUser user, Data data) { Logger.Log("Identify received!"); User server_user = new User(data.Input); server_user.SetSocket(user); user.SetUser(server_user); user.Send((byte)ClientCodes.Identified, "Welcome " + server_user.Name); }