mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
Handle
This commit is contained in:
@@ -42,9 +42,9 @@ public abstract class PacketFilter : IResource
|
||||
}
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
|
||||
|
||||
public abstract AsyncReply<bool> Handle(ResourceOperation trigger);
|
||||
|
||||
public abstract AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null);
|
||||
|
||||
public abstract bool Execute(Packet packet);
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@ public class PacketServer : IResource
|
||||
OnDestroy?.Invoke(this);
|
||||
}
|
||||
|
||||
public AsyncReply<bool> Trigger(ResourceOperation trigger)
|
||||
public AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null)
|
||||
{
|
||||
if (trigger == ResourceOperation.Initialize)
|
||||
if (operation == ResourceOperation.Initialize)
|
||||
{
|
||||
foreach (var src in sources)
|
||||
{
|
||||
@@ -77,12 +77,12 @@ public class PacketServer : IResource
|
||||
src.Open();
|
||||
}
|
||||
}
|
||||
else if (trigger == ResourceOperation.Terminate)
|
||||
else if (operation == ResourceOperation.Terminate)
|
||||
{
|
||||
foreach (var src in sources)
|
||||
src.Close();
|
||||
}
|
||||
else if (trigger == ResourceOperation.SystemReload)
|
||||
else if (operation == ResourceOperation.SystemReloading)
|
||||
{
|
||||
foreach (var src in sources)
|
||||
{
|
||||
|
||||
@@ -43,9 +43,7 @@ public abstract class PacketSource : IResource
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
public abstract AsyncReply<bool> Trigger(ResourceOperation trigger);
|
||||
|
||||
public abstract AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null);
|
||||
|
||||
public abstract bool RawMode
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Text;
|
||||
namespace Esiur.Net.Http;
|
||||
public class EpOverHttp : HttpFilter
|
||||
{
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
EntryPoint EntryPoint { get; set; }
|
||||
|
||||
public override AsyncReply<bool> Execute(HttpConnection sender)
|
||||
@@ -30,7 +30,7 @@ public class EpOverHttp : HttpFilter
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
public override AsyncReply<bool> Trigger(ResourceOperation trigger)
|
||||
public override AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null)
|
||||
{
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
@@ -33,9 +33,10 @@ using Esiur.Core;
|
||||
using Esiur.Protocol;
|
||||
|
||||
namespace Esiur.Net.Http;
|
||||
|
||||
public class EpOvwerWebsocket : HttpFilter
|
||||
{
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public EpServer Server
|
||||
{
|
||||
get;
|
||||
@@ -72,7 +73,7 @@ public class EpOvwerWebsocket : HttpFilter
|
||||
|
||||
}
|
||||
|
||||
public override AsyncReply<bool> Trigger(ResourceOperation trigger)
|
||||
public override AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null)
|
||||
{
|
||||
return new AsyncReply<bool>(true);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class HttpFilter : IResource
|
||||
}
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
public abstract AsyncReply<bool> Trigger(ResourceOperation trigger);
|
||||
public abstract AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null);
|
||||
|
||||
/*
|
||||
public virtual void SessionModified(HTTPSession session, string key, object oldValue, object newValue)
|
||||
|
||||
@@ -139,14 +139,14 @@ public class HttpServer : NetworkServer<HttpConnection>, IResource
|
||||
set;
|
||||
}
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public virtual string IP
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public virtual ushort Port
|
||||
{
|
||||
get;
|
||||
@@ -154,21 +154,21 @@ public class HttpServer : NetworkServer<HttpConnection>, IResource
|
||||
}
|
||||
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public virtual uint MaxPost
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public virtual bool SSL
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public virtual string Certificate
|
||||
{
|
||||
get;
|
||||
@@ -291,10 +291,10 @@ public class HttpServer : NetworkServer<HttpConnection>, IResource
|
||||
*/
|
||||
|
||||
|
||||
public async AsyncReply<bool> Trigger(ResourceOperation trigger)
|
||||
public async AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null)
|
||||
{
|
||||
|
||||
if (trigger == ResourceOperation.Initialize)
|
||||
if (operation == ResourceOperation.Initialize)
|
||||
{
|
||||
//var ip = (IPAddress)Instance.Attributes["ip"];
|
||||
//var port = (int)Instance.Attributes["port"];
|
||||
@@ -318,16 +318,16 @@ public class HttpServer : NetworkServer<HttpConnection>, IResource
|
||||
|
||||
Start(listener);
|
||||
}
|
||||
else if (trigger == ResourceOperation.Terminate)
|
||||
else if (operation == ResourceOperation.Terminate)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
else if (trigger == ResourceOperation.SystemReload)
|
||||
else if (operation == ResourceOperation.SystemReloading)
|
||||
{
|
||||
await Trigger(ResourceOperation.Terminate);
|
||||
await Trigger(ResourceOperation.Initialize);
|
||||
await Handle(ResourceOperation.Terminate);
|
||||
await Handle(ResourceOperation.Initialize);
|
||||
}
|
||||
else if (trigger == ResourceOperation.SystemInitialized)
|
||||
else if (operation == ResourceOperation.SystemReady)
|
||||
{
|
||||
filters = await Instance.Children<HttpFilter>();
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class NetworkServer<TConnection> : IDestructible where TConnecti
|
||||
}
|
||||
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public uint Timeout
|
||||
{
|
||||
get;
|
||||
@@ -144,7 +144,7 @@ public abstract class NetworkServer<TConnection> : IDestructible where TConnecti
|
||||
}
|
||||
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public uint Clock
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class TcpFilter : IResource
|
||||
public event DestroyedEvent OnDestroy;
|
||||
|
||||
|
||||
public abstract AsyncReply<bool> Trigger(ResourceOperation trigger);
|
||||
public abstract AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null);
|
||||
|
||||
public virtual bool Connected(TcpConnection sender)
|
||||
{
|
||||
|
||||
@@ -38,13 +38,13 @@ namespace Esiur.Net.Tcp;
|
||||
public class TcpServer : NetworkServer<TcpConnection>, IResource
|
||||
{
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public string IP
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
public ushort Port
|
||||
{
|
||||
get;
|
||||
@@ -66,9 +66,9 @@ public class TcpServer : NetworkServer<TcpConnection>, IResource
|
||||
|
||||
TcpFilter[] filters = null;
|
||||
|
||||
public AsyncReply<bool> Trigger(ResourceOperation trigger)
|
||||
public AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null)
|
||||
{
|
||||
if (trigger == ResourceOperation.Initialize)
|
||||
if (operation == ResourceOperation.Initialize)
|
||||
{
|
||||
TcpSocket listener;
|
||||
|
||||
@@ -82,16 +82,16 @@ public class TcpServer : NetworkServer<TcpConnection>, IResource
|
||||
|
||||
|
||||
}
|
||||
else if (trigger == ResourceOperation.Terminate)
|
||||
else if (operation == ResourceOperation.Terminate)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
else if (trigger == ResourceOperation.SystemReload)
|
||||
else if (operation == ResourceOperation.SystemReloading)
|
||||
{
|
||||
Trigger(ResourceOperation.Terminate);
|
||||
Trigger(ResourceOperation.Initialize);
|
||||
Handle(ResourceOperation.Terminate);
|
||||
Handle(ResourceOperation.Initialize);
|
||||
}
|
||||
else if (trigger == ResourceOperation.SystemInitialized)
|
||||
else if (operation == ResourceOperation.SystemReady)
|
||||
{
|
||||
Instance.Children<TcpFilter>().Then(x => filters = x);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ public abstract class UdpFilter : IResource
|
||||
|
||||
public event DestroyedEvent OnDestroy;
|
||||
|
||||
public abstract AsyncReply<bool> Trigger(ResourceOperation trigger);
|
||||
public abstract AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null);
|
||||
|
||||
|
||||
public abstract bool Execute(byte[] data, IPEndPoint sender);
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ public class UdpServer : IResource
|
||||
set;
|
||||
}
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
string IP
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[Attribute]
|
||||
//[Attribute]
|
||||
ushort Port
|
||||
{
|
||||
get;
|
||||
@@ -177,9 +177,9 @@ public class UdpServer : IResource
|
||||
OnDestroy?.Invoke(this);
|
||||
}
|
||||
|
||||
async AsyncReply<bool> IResource.Trigger(ResourceOperation trigger)
|
||||
public async AsyncReply<bool> Handle(ResourceOperation operation, IResourceContext context = null)
|
||||
{
|
||||
if (trigger == ResourceOperation.Initialize)
|
||||
if (operation == ResourceOperation.Initialize)
|
||||
{
|
||||
var address = IP == null ? IPAddress.Any : IPAddress.Parse(IP);
|
||||
|
||||
@@ -188,12 +188,12 @@ public class UdpServer : IResource
|
||||
receiver = new Thread(Receiving);
|
||||
receiver.Start();
|
||||
}
|
||||
else if (trigger == ResourceOperation.Terminate)
|
||||
else if (operation == ResourceOperation.Terminate)
|
||||
{
|
||||
if (receiver != null)
|
||||
receiver.Abort();
|
||||
}
|
||||
else if (trigger == ResourceOperation.SystemInitialized)
|
||||
else if (operation == ResourceOperation.SystemReady)
|
||||
{
|
||||
filters = await Instance.Children<UdpFilter>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user