Beispiel #1
0
        public static void TcpCommandReceived(int idClient, Packet packet)
        {
            int    clientIdCheck = packet.ReadInt();
            string msg           = packet.ReadString();

            string[] cmd;

            if (string.IsNullOrWhiteSpace(msg = msg.Trim()))
            {
                return;
            }
            if (msg[0] == '/')
            {
                cmd = msg.Split(' ');

                if (/*HasPriviliege(idClient)*/ true)
                {
                    switch (cmd[0].ToLower())
                    {
                    case "/tp":
                        Console.WriteLine("Tp command issued");
                        break;

                    case "/w":
                        Console.WriteLine("Whisper command issued");
                        break;

                    default:
                        Console.WriteLine("Unrecognized command");
                        break;
                    }
                }
                return;
            }

            if (clientIdCheck != idClient)
            {
                Console.WriteLine("L'id is corrupted " + clientIdCheck);
                return;
            }
            Console.WriteLine($"[{Game.Players[idClient].Name }, {idClient}]: { msg }");
            ServerSend.TcpSpreadChatMessageToAll(Game.Players[idClient], msg);
        }
Beispiel #2
0
 public void Connect(IPEndPoint _endPoint)
 {
     endPoint = _endPoint;
     ServerSend.UDPTest(id);
 }