static void Server_ClientConnected(object sender, ServerClientEventArgs e) { Console.WriteLine("A new client is connected. Client Id = " + e.Client.ClientId); //Register to MessageReceived event to receive messages from new client e.Client.MessageReceived += Client_MessageReceived; }
protected void OnConnected(object sender, ServerClientEventArgs e) { // ReSharper disable StringIndexOfIsCultureSpecific.1 string ip = Regex.Match(e.Client.RemoteEndPoint.ToString(), "([0-9]+).([0-9]+).([0-9]+).([0-9]+)").Value; // ReSharper restore StringIndexOfIsCultureSpecific.1 //useless? // if (ip == "192.168.150") // return; // Log.Info("Client connected!"); if (ConnectionsTime.ContainsKey(ip)) { if (Funcs.GetCurrentMilliseconds() - ConnectionsTime[ip] < 2000) { Process.Start("cmd", "/c netsh advfirewall firewall add rule name=\"AutoBAN (" + ip + ")\" protocol=TCP dir=in remoteip=" + ip + " action=block"); ConnectionsTime.Remove(ip); Log.Info("TcpServer: FloodAttack prevent! Ip " + ip + " added to firewall"); return; } ConnectionsTime[ip] = Funcs.GetCurrentMilliseconds(); } else ConnectionsTime.Add(ip, Funcs.GetCurrentMilliseconds()); new Connection(e.Client); }
protected void OnConnected(object sender, ServerClientEventArgs e) { string ip = Regex.Match(e.Client.RemoteEndPoint.ToString(), "([0-9]+).([0-9]+).([0-9]+).([0-9]+)").Value; // Skip web connect if (ip == "159.253.18.161") return; Log.Info("Client connected!"); if (ConnectionsTime.ContainsKey(ip)) { if (Funcs.GetCurrentMilliseconds() - ConnectionsTime[ip] < 2000) { /*Process.Start("cmd", "/c netsh advfirewall firewall add rule name=\"AutoBAN (" + ip + ")\" protocol=TCP dir=in remoteip=" + ip + " action=block"); ConnectionsTime.Remove(ip); Log.Info("TcpServer: FloodAttack prevent! Ip " + ip + " added to firewall"); return;*/ } ConnectionsTime[ip] = Funcs.GetCurrentMilliseconds(); } else ConnectionsTime.Add(ip, Funcs.GetCurrentMilliseconds()); new NetSession(e.Client); }
protected void OnConnected(object sender, ServerClientEventArgs e) { string ip = Regex.Match(e.Client.RemoteEndPoint.ToString(), "([0-9]+).([0-9]+).([0-9]+).([0-9]+)").Value; Logger.WriteLine(LogState.Info,"Client connected!"); if (ConnectionsTime.ContainsKey(ip)) { if (RandomUtilities.GetCurrentMilliseconds() - ConnectionsTime[ip] < 2000) { Process.Start("cmd", "/c netsh advfirewall firewall add rule name=\"AutoBAN (" + ip + ")\" protocol=TCP dir=in remoteip=" + ip + " action=block"); ConnectionsTime.Remove(ip); Logger.WriteLine(LogState.Info,"TcpServer: FloodAttack prevent! Ip " + ip + " added to firewall"); return; } ConnectionsTime[ip] = RandomUtilities.GetCurrentMilliseconds(); } else ConnectionsTime.Add(ip, RandomUtilities.GetCurrentMilliseconds()); new Connection(e.Client); }
protected void OnConnected(object sender, ServerClientEventArgs e) { if (Connections.Count >= MaxConnections) { e.Client.Disconnect(); return; } Log.Info("Client connected!"); Connections.Add(e.Client, new Connection(e.Client, true)); }
protected void OnConnected(object sender, ServerClientEventArgs e) { Log.Info("Client [{0}] connected!", e.Client.RemoteEndPoint); ConnectionsCount++; if (ConnectionsCount > MaxConnections) { e.Client.Disconnect(); return; } new Connection(e.Client, true); }
void ClientDisconnected(object sender, ServerClientEventArgs e) { e.Client.MessageReceived -= new EventHandler<MessageEventArgs>(ClientMessageReceived); e.Client.MessageSent -= new EventHandler<MessageEventArgs>(ClientMessageSent); try { string name; clients.TryRemove(e.Client, out name); logger.Debug("Client Disconnected: {0}, {1}", e.Client.ClientId, name); } catch (Exception ex) { logger.Debug(ex.ToString()); } }
static void server_ClientConnected(object sender, ServerClientEventArgs e) { e.Client.MessageReceived += Client_MessageReceived; }
protected void server_ClientDisconnected(object sender, ServerClientEventArgs e) { EzLogger.GlobalLogger.info(string.Format("{0} client(s). disconnected: {1}", _server.Clients.Count, e.Client.RemoteEndPoint)); try { lock (_sclients) { _sclients.Remove(e.Client.ClientId); } } catch { } if (ConnectionDropped != null) ConnectionDropped(e.Client); }
protected void OnDisconnected(object sender, ServerClientEventArgs e) { Logger.WriteLine(LogState.Info,"Client disconnected!"); }
protected void OnDisconnected(object sender, ServerClientEventArgs e) { Log.Info("Client disconnected!"); }
static void server_ClientConnected(object sender, ServerClientEventArgs e) { Console.WriteLine("Client {0} connected at {1}.", e.Client.ClientId, e.Client.RemoteEndPoint); e.Client.MessageReceived += Client_MessageReceived; }
protected void OnDisconnected(object sender, ServerClientEventArgs e) { }
protected void OnConnected(object sender, ServerClientEventArgs e) { Log.Info("InnerClient connected!"); new OuterNetworkConnection(e.Client); }
protected void OnDisconnected(object sender, ServerClientEventArgs e) { Connections.Remove(e.Client); Log.Info("Client disconnected!"); }
static void Server_ClientDisconnected(object sender, ServerClientEventArgs e) { Console.WriteLine("A client is disconnected! Client Id = " + e.Client.ClientId); }
protected void server_ClientConnected(object sender, ServerClientEventArgs e) { e.Client.MessageReceived += Client_MessageReceived; EzLogger.GlobalLogger.info(string.Format("{0} client(s). connected: {1}", _server.Clients.Count, e.Client.RemoteEndPoint)); try { ServerClientDictItem sc = new ServerClientDictItem(e.Client, this.DefaultLifeNumber); lock (_sclients) { _sclients.Add(e.Client.ClientId, sc); } } catch (System.Exception ex) { EzLogger.GlobalLogger.warning(string.Format("{0}{2}{1}{2}", ex.Message, ex.StackTrace, Environment.NewLine)); } if (ConnectionArrived != null) ConnectionArrived(e.Client); }
void ClientConnected(object sender, ServerClientEventArgs e) { e.Client.MessageReceived += new EventHandler<MessageEventArgs>(ClientMessageReceived); e.Client.MessageSent += new EventHandler<MessageEventArgs>(ClientMessageSent); logger.Debug("Client Connected: {0}", e.Client.ClientId); }
static void server_ClientConnected(object sender, ServerClientEventArgs e) { Console.WriteLine("A new client is connected. Address: " + e.Client.RemoteEndPoint); e.Client.MessageReceived += Client_MessageReceived; }