protected virtual void OnAcceptConnection(Socket socket) { var xSocket = new XSocket(socket); _clientsConnected.Add(xSocket); OnAccept?.Invoke(this, new XSocketArgs(xSocket)); }
/// <summary> /// Attempting a connection /// First will connect using TcpClient => Preventing bugs then transferring it to XSocket /// </summary> private async Task TryConnection() { try { var tcpClient = new TcpClient(); await tcpClient.ConnectAsync("127.0.0.1", _port); if (tcpClient.Connected) { _socket = new XSocket(tcpClient.Client); _socket.OnReceive += XSocketOnOnReceive; _socket.ConnectionClosedEvent += SocketOnConnectionClosedEvent; _socket.Read(true); _socket.Write("sini|" + _client.CurrentUser.Id + "|" + _client.CurrentUser.Username + "#" + _client.CurrentUser.DiscriminatorValue); _connectionFactor = true; } } catch (Exception) { _connectionFactor = false; } }
public XSocketArgs(XSocket xSocket) { XSocket = xSocket; }