public LoginResult Login(ClienNetworkManager client, PacketLoginRequest packet) { ChatUserServer user = null; lock (this.Users) { if (this.Users.Any(u => u.LoginToken.Equals(packet.LoginToken)) == true) { return(new LoginResult() { ErrorMessage = "Already Logined Account" }); } else { var sessionToken = Guid.NewGuid().ToString(); user = new ChatUserServer(packet.LoginToken, sessionToken, client); user.DisplayName = packet.DisplayName; this.Users.Add(user); this.OnLogined(user); return(new LoginResult() { User = user }); } } }
private void Accepting() { var listener = this.Listener = new TcpListener(new IPEndPoint(IPAddress.Any, 1653)); try { listener.Start(); while (true) { var tcpClient = listener.AcceptTcpClient(); tcpClient.NoDelay = true; var client = new ClienNetworkManager(this, tcpClient); lock (this.Clients) { this.Clients.Add(client); } } } catch (Exception e) { var server = Server.Instance; server.Console.SendMessage("Accepting Uncatched Exception"); server.Console.SendMessage(e.ToString()); } finally { listener.Stop(); } }
public PacketHandlerServer(ClienNetworkManager client, ChatUserServer user) { this.Client = client; this.User = user; this.LastKeepAliveTicks = 0L; this.KeepAliveInterval = 50; this.Ping = 0L; }
public PacketHandlerHandshake(ClienNetworkManager networkManager) { this.Client = networkManager; }
public ChatUserServer(string loginToken, string sessionToken, ClienNetworkManager networkManager) : base() { this.LoginToken = loginToken; this.SessionToken = sessionToken; this.NetworkManager = networkManager; }