private void OutgoingSocket_OnDisconnect(WinsockClient sender, object obj) { if (ClientSocket.Connected) ClientSocket.Disconnect(false); ClientSocket.Dispose(); Console.WriteLine("Client Disconnected"); }
private void OutgoingSocket_OnReceive(WinsockClient sender, byte[] data) { if (Functions.PacketSniffing.Sniffing) Functions.PacketSniffing.Sniff(data, true); Connections.PacketHandler.HandleAuthentication(this, data); this.IncomingSocket.Send(data); }
public void StartSending() { this.OutgoingSocket = new WinsockClient(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.OutgoingSocket.OnReceive += new SocketEventCallback<WinsockClient, byte[]>(OutgoingSocket_OnReceive); this.OutgoingSocket.OnDisconnect += new SocketEventCallback<WinsockClient, object>(OutgoingSocket_OnDisconnect); this.OutgoingSocket.Enable(Program.AuthAddress, this.Port, this.Data); }
private static unsafe void OnClientReceive(WinsockClient Socket, byte[] Packet, int Length) { GameClient Client = Socket.Wrapper as GameClient; Client.Decrypt(Packet); PacketProcessor.Process(Client, Packet); }
public Client(Socket incoming, ushort port) { this.ClientSocket = incoming; this.ServerSocket = new WinsockClient(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.ServerSocket.OnReceive += new SocketEventCallback<WinsockClient, byte[]>(OutgoingSocket_OnReceive); this.ServerSocket.OnDisconnect += new SocketEventCallback<WinsockClient, object>(OutgoingSocket_OnDisconnect); this.ServerSocket.Enable(Program.GameAddress, port, Data); }
private void OutgoingSocket_OnReceive(WinsockClient sender, byte[] buffer) { if (this.Exchange && buffer.Length > 36) { this.SendToClient(buffer); } else Connections.PacketHandler.HandleBuffer(this, buffer, false); }
private static void OnClientDisconnect(WinsockClient Socket, object NullParam) { GameClient Client = Socket.Wrapper as GameClient; Database.SaveCharacter(Client); Client.RemoveFromScreen(); EntityManager.Remove(Client); }
private static unsafe void OnClientReceive(WinsockClient Socket, byte[] Packet, int Length) { AuthClient Client = Socket.Wrapper as AuthClient; Client.Decrypt(Packet); fixed(byte *pPacket = Packet) { ushort Size = *(ushort *)pPacket; ushort Type = *(ushort *)(pPacket + 2); HexDump(Packet, "Client -> Server", Size, Type); switch (Type) { case 0x41B: { AuthRequest *Request = (AuthRequest *)pPacket; string Username = new string(Request->Username, 0, 16).Trim('\x00'); string Password = PasswordCipher.Decrypt((uint *)Request->Password); string Server = new string(Request->Server, 0, 16).Trim('\x00'); string Address = ""; if (Database.ServerExists(Server, out Address)) { if (Database.AccountExists(Username, Password, Client)) { #if LOCAL_VERSION IPHostEntry entry = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress address in entry.AddressList) { if (address.AddressFamily == AddressFamily.InterNetwork) { string local_ip = address.ToString(); if (local_ip.StartsWith("10")) { Address = local_ip; break; } } } #endif SendAuthResponse(Client, Address, 5816); } else { SendAuthReject(Client, InvalidCredentials()); //Client.Disconnect(); } } } break; } } }
public LoginPlayer(CSockState clientSocket, string authIp, int authPort) { _clientSocket = clientSocket.Socket; authServerBuffer = new byte[1024]; //Establish connection to actual auth server _serverSocket = new WinsockClient(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp); _serverSocket.Enable(authIp, (ushort)authPort, authServerBuffer); _serverSocket.OnConnect += _serverSocket_OnConnect; _serverSocket.OnDisconnect += _serverSocket_OnDisconnect; _serverSocket.OnReceive += _serverSocket_OnReceive; }
private void _serverSocket_OnDisconnect(WinsockClient Sender, object Arg) { //Disconnect both sockets try { if (_serverSocket.Connected) { _serverSocket.Disconnect(); } if (_clientSocket.Connected) { _clientSocket.Disconnect(false); } } catch { } }
public GameClient(WinsockClient Socket) { this.Socket = Socket; SendLock = new object(); Cryptography = new GameCryptography(); Cryptography.Initialize(); Entity = new Entity(this); Screen = new Screen(this); PacketQueue = new PacketQueue(); Inventory = new List <ConquerItem>(); Profiencys = new List <LearnProfiency>(); Spells = new List <LearnSpell>(); Equipment = new Dictionary <ItemPosition, ConquerItem>(); Status = LoginStatus.Logging; }
public AuthClient(WinsockClient Socket) { this.Socket = Socket; Cipher = new AuthCryptography(); Cipher.Initialize(); }
private static void OnClientDisconnect(WinsockClient Socket, object NullParam) { }
private static void OnClientConnect(WinsockClient Socket, object NullParam) { Socket.Wrapper = new AuthClient(Socket); }
private void _serverSocket_OnReceive(WinsockClient Sender, byte[] Arg) { //Decrypt }
private void _serverSocket_OnConnect(WinsockClient Sender, object Arg) { Log.LogToConsole("Connected to auth server", LogSource.Auth); }
private void OutgoingSocket_OnDisconnect(WinsockClient sender, object arg) { }