mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 03:32:57 +00:00
Filters
This commit is contained in:
parent
216b891bf8
commit
2cf0d59e6b
@ -220,17 +220,13 @@ public abstract class NetworkServer<TConnection> : IDestructible where TConnecti
|
||||
|
||||
public virtual void Remove(TConnection connection)
|
||||
{
|
||||
//connection.OnDataReceived -= OnDataReceived;
|
||||
//connection.OnConnect -= OnClientConnect;
|
||||
connection.OnClose -= ClientDisconnectedEventReceiver;
|
||||
Connections.Remove(connection);
|
||||
}
|
||||
|
||||
public virtual void Add(TConnection connection)
|
||||
{
|
||||
//connection.OnDataReceived += OnDataReceived;
|
||||
//connection.OnConnect += OnClientConnect;
|
||||
connection.OnClose += ClientDisconnectedEventReceiver;// OnClientClose;
|
||||
connection.OnClose += ClientDisconnectedEventReceiver;
|
||||
Connections.Add(connection);
|
||||
}
|
||||
|
||||
@ -283,19 +279,12 @@ public abstract class NetworkServer<TConnection> : IDestructible where TConnecti
|
||||
{
|
||||
var con = connection as TConnection;
|
||||
con.Destroy();
|
||||
// con.OnClose -= ClientDisconnectedEventReceiver;
|
||||
|
||||
Remove(con);
|
||||
|
||||
//Connections.Remove(con);
|
||||
ClientDisconnected(con);
|
||||
//RemoveConnection((TConnection)sender);
|
||||
//connections.Remove(sender)
|
||||
//ClientDisconnected((TConnection)sender);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Global.Log("NetworkServer:OnClientDisconnect", LogType.Error, ex.ToString());
|
||||
Global.Log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,10 @@ public class TCPServer : NetworkServer<TCPConnection>, IResource
|
||||
|
||||
internal bool Execute(TCPConnection sender, NetworkBuffer data)
|
||||
{
|
||||
|
||||
if (filters == null)
|
||||
return false;
|
||||
|
||||
var msg = data.Read();
|
||||
|
||||
foreach (var filter in filters)
|
||||
@ -123,6 +127,8 @@ public class TCPServer : NetworkServer<TCPConnection>, IResource
|
||||
|
||||
protected override void ClientDisconnected(TCPConnection connection)
|
||||
{
|
||||
if (filters == null)
|
||||
return;
|
||||
|
||||
foreach (var filter in filters)
|
||||
{
|
||||
@ -144,6 +150,9 @@ public class TCPServer : NetworkServer<TCPConnection>, IResource
|
||||
|
||||
protected override void ClientConnected(TCPConnection connection)
|
||||
{
|
||||
if (filters == null)
|
||||
return;
|
||||
|
||||
foreach (var filter in filters)
|
||||
{
|
||||
filter.Connected(connection);
|
||||
|
Loading…
x
Reference in New Issue
Block a user