public static void OnWelcomeResponse(Packet packet) { string msg = packet.ReadString(); int id = packet.ReadInt(); int tickRate = packet.ReadInt(); Console.WriteLine("Message from the server : " + msg); Client.myId = id; ClientSend.WelcomeReceived(); Client.udp.Connect(((IPEndPoint)Client.tcp.socket.Client.LocalEndPoint).Port); }
private static void TextThread() { while (isRunning) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write($">{Name}=-> "); Console.ForegroundColor = ConsoleColor.DarkBlue; ClientSend.Message(Console.ReadLine()); Console.ResetColor(); } }
public static void Welcome(Packet _packet) { //Look out with the order, it's important int _myId = _packet.ReadInt(); string _msg = _packet.ReadString(); Console.WriteLine($"Server: {_msg}"); Client.Instance.myId = _myId; //send welcome received packet ClientSend.WelcomeReceived(); }
static void Main(string[] args) { Console.Title = "[POC TCP/UDP] Client"; //get name from console Console.Write("Type your name: "); string inputName = Console.ReadLine(); //Start UDP/FTP client. Client.Instance.ConnectToServer(inputName); //message/app loop while (true) { string inputText = Console.ReadLine(); ClientSend.Message(inputName, inputText); } }
public static void WelcomeR(Packet packet) { Client.Instance.id = packet.ReadInt(); int sTps = packet.ReadInt(); string msg = packet.ReadString(); int ServerHash = packet.ReadInt(); int thisHash = HashCode.Combine(Client.Instance.tcp.socket.Client.RemoteEndPoint.ToString(), Client.Instance.port); Console.WriteLine($"Server TPS is: {sTps}"); Client.Instance.udp.Conect(((IPEndPoint)Client.Instance.tcp.socket.Client.LocalEndPoint).Port); if (ServerHash != thisHash) { Console.WriteLine($"Servers Hash ({ServerHash}) was not equal to our Hash ({thisHash})"); Console.WriteLine($"Message from the Server : {msg}"); ClientSend.WelcomeRecS(false, thisHash); } else { Console.WriteLine($"Message from the Server {ServerHash}: {msg}"); ClientSend.WelcomeRecS(true); } }
public static void SendMessage(string msg, int idHandler) { ClientSend.SendMessage(msg, idHandler); }