mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 11:32:59 +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)
|
public virtual void Remove(TConnection connection)
|
||||||
{
|
{
|
||||||
//connection.OnDataReceived -= OnDataReceived;
|
|
||||||
//connection.OnConnect -= OnClientConnect;
|
|
||||||
connection.OnClose -= ClientDisconnectedEventReceiver;
|
connection.OnClose -= ClientDisconnectedEventReceiver;
|
||||||
Connections.Remove(connection);
|
Connections.Remove(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Add(TConnection connection)
|
public virtual void Add(TConnection connection)
|
||||||
{
|
{
|
||||||
//connection.OnDataReceived += OnDataReceived;
|
connection.OnClose += ClientDisconnectedEventReceiver;
|
||||||
//connection.OnConnect += OnClientConnect;
|
|
||||||
connection.OnClose += ClientDisconnectedEventReceiver;// OnClientClose;
|
|
||||||
Connections.Add(connection);
|
Connections.Add(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,19 +279,12 @@ public abstract class NetworkServer<TConnection> : IDestructible where TConnecti
|
|||||||
{
|
{
|
||||||
var con = connection as TConnection;
|
var con = connection as TConnection;
|
||||||
con.Destroy();
|
con.Destroy();
|
||||||
// con.OnClose -= ClientDisconnectedEventReceiver;
|
|
||||||
|
|
||||||
Remove(con);
|
Remove(con);
|
||||||
|
|
||||||
//Connections.Remove(con);
|
|
||||||
ClientDisconnected(con);
|
ClientDisconnected(con);
|
||||||
//RemoveConnection((TConnection)sender);
|
|
||||||
//connections.Remove(sender)
|
|
||||||
//ClientDisconnected((TConnection)sender);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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)
|
internal bool Execute(TCPConnection sender, NetworkBuffer data)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (filters == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
var msg = data.Read();
|
var msg = data.Read();
|
||||||
|
|
||||||
foreach (var filter in filters)
|
foreach (var filter in filters)
|
||||||
@ -123,6 +127,8 @@ public class TCPServer : NetworkServer<TCPConnection>, IResource
|
|||||||
|
|
||||||
protected override void ClientDisconnected(TCPConnection connection)
|
protected override void ClientDisconnected(TCPConnection connection)
|
||||||
{
|
{
|
||||||
|
if (filters == null)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var filter in filters)
|
foreach (var filter in filters)
|
||||||
{
|
{
|
||||||
@ -144,6 +150,9 @@ public class TCPServer : NetworkServer<TCPConnection>, IResource
|
|||||||
|
|
||||||
protected override void ClientConnected(TCPConnection connection)
|
protected override void ClientConnected(TCPConnection connection)
|
||||||
{
|
{
|
||||||
|
if (filters == null)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var filter in filters)
|
foreach (var filter in filters)
|
||||||
{
|
{
|
||||||
filter.Connected(connection);
|
filter.Connected(connection);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user