public Task ServersList(Client client, string packet) => Task.Run(async() => { var rawPacket = PacketsReceiver.GetPacketContent(packet).Split('|').Distinct().ToList(); DateTime subEndDate = StringHelper.UnixTimeStampToDateTime(long.Parse(rawPacket[0])); //StringHelper.WriteLine($"[{client.Username}:{client.Password}] is subscribed, end date : {subEndDate.Day}/{subEndDate.Month}/{subEndDate.Year}", ConsoleColor.Green); await client.Network.SendPacket($"AX624"); });
public Task Connection(Client client, string packet) => Task.Run(async() => { var key = PacketsReceiver.GetPacketContent(packet); StringHelper.WriteLine($"[{client.Username}:{client.Password}] got key : {key}"); await client.Network.SendPacket(Constants.GameVersion); await client.Network.SendPacket(client.Username + "\n" + Hash.Encrypt(client.Password, key)); await client.Network.SendPacket("Af"); });
public void GetServersStates(Client client, string packet) { string[] availableServersDatas = PacketsReceiver.GetPacketContent(packet).Substring(2).Split('|'); //foreach (string servDatas in availableServersDatas) //{ // //string[] splitter = servDatas.Split(';'); // //int id = int.Parse(splitter[0]); // //ServerStatus state = (ServerStatus)byte.Parse(splitter[1]); //} }
public void AuthentificationFailed(Client client, string packet) { StringHelper.WriteLine($"[{client.Username}:{client.Password}] can't login.", ConsoleColor.Red); if (PacketsReceiver.GetPacketContent(packet).StartsWith("v")) { Constants.GameVersion = PacketsReceiver.GetPacketContent(packet).Replace("v", ""); StringHelper.WriteLine($"[{client.Username}:{client.Password}] New version has been set ! Reconnecting..", ConsoleColor.Green); client.Reconnect(); } client.Network.Dispose(); }
public Client(int playerId, UdpClient udpClient, PacketsReceiver packetsReceiver, PacketsSender packetsSender, PlayersManager playersManager, MetaMonoBehaviours metaMonoBehaviours) { this.playerId = playerId; tcpConnection = null; udpIpEndPoint = null; this.metaMonoBehaviours = metaMonoBehaviours; this.udpClient = udpClient; this.packetsReceiver = packetsReceiver; this.packetsSender = packetsSender; this.playersManager = playersManager; }
public TcpConnection(int playerId, TcpClient tcpClient, PacketsReceiver packetsReceiver, PacketsSender packetsSender, PlayersManager playersManager, MetaMonoBehaviours metaMonoBehaviours) : base(metaMonoBehaviours) { this.playerId = playerId; receivePacket = new Packet(); receiveBuffer = new byte[DataBufferSize]; this.packetsReceiver = packetsReceiver; this.packetsSender = packetsSender; this.playersManager = playersManager; this.metaMonoBehaviours = metaMonoBehaviours; this.tcpClient = tcpClient; this.tcpClient.ReceiveBufferSize = DataBufferSize; this.tcpClient.SendBufferSize = DataBufferSize; }
public TcpConnection(ConnectionToServer connectionToServer, PacketsReceiver packetsReceiver, MetaMonoBehaviours metaMonoBehaviours) : base(metaMonoBehaviours) { this.connectionToServer = connectionToServer; this.packetsReceiver = packetsReceiver; tcpClient = new TcpClient { ReceiveBufferSize = DataBufferSize, SendBufferSize = DataBufferSize }; receiveBuffer = new byte[DataBufferSize]; tcpClient.BeginConnect(ConnectionToServer.ServerIP, ConnectionToServer.ServerPort, ConnectCallback, tcpClient); Logger.LogEvent(LoggerSection.Network, "Started listening for tcp connections"); }
private static void Main() { Debug = Debugger.IsAttached; Console.OutputEncoding = System.Text.Encoding.UTF8; StringHelper.WriteLine("Initializing..", ConsoleColor.Blue); DataManager.Initialize(); MapKeyCracker.Initialize(); PacketsReceiver.Initialize(); StringHelper.WriteLine("Initialization done, starting..", ConsoleColor.Gray); Client bot1 = null; var task = Task.Factory.StartNew(() => { bot1 = new Client("", ""); }); while (true) { Thread.Sleep(100); } }
public UdpConnection(ConnectionToServer connectionToServer, MetaMonoBehaviours metaMonoBehaviours, PacketsReceiver packetsReceiver, int localPort) { this.connectionToServer = connectionToServer; this.metaMonoBehaviours = metaMonoBehaviours; this.packetsReceiver = packetsReceiver; ipEndPoint = new IPEndPoint(IPAddress.Parse(ConnectionToServer.ServerIP), ConnectionToServer.ServerPort); udpClient = new UdpClient(localPort); udpClient.Connect(ipEndPoint); udpClient.BeginReceive(OnConnection, null); Logger.LogEvent(LoggerSection.Connection, "Started listening for udp connections"); Packet packet = new Packet(); SendPacket(packet); Logger.LogEvent(LoggerSection.Connection, "Sent first empty udp packet to connect with server's udp"); }
public void ProcessReceive(object sender, SocketAsyncEventArgs args) { try { args.Completed -= ProcessReceive; var bytesReceived = args.BytesTransferred; if (args.LastOperation != SocketAsyncOperation.Receive || bytesReceived == 0) { //Disconnect(); return; } if (bytesReceived > 0) { var data = Encoding.UTF8.GetString(this.Buffer, 0, bytesReceived); //if (Program.Debug) //{ // string finalStr = ""; // foreach (var value in this.Buffer) // { // if (value == 0) // { // StringHelper.WriteLine(finalStr, ConsoleColor.Gray); // break; // } // finalStr += value + " "; // } //} Ping.Update(); foreach (var packet in data.Replace("\x0a", string.Empty).Split('\x00').Where(x => x != "")) { StringHelper.WriteLine($"→ RCV {packet}"); PacketsReceiver.Receive(this.Client, packet); } } Receive(); } catch (Exception ex) { StringHelper.WriteLine($"X Error {ex.Message}", ConsoleColor.DarkRed); } }
public void AuthentificationQueue(Client client, string packet) { packet = PacketsReceiver.GetPacketContent(packet); StringHelper.WriteLine($"Queue position {packet.Split('|')[0]}/{packet.Split('|')[1]}"); }