Skip to content

Commit

Permalink
HTTP.ServerOn -> remove server scope
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Jun 27, 2024
1 parent 6df8794 commit 128a938
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/http/partials/Server/HTTP.ServerOn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,31 @@ namespace Netly
{
public partial class HTTP
{
public partial class Server
internal class ServerOn : IHTTP.ServerOn
{
internal class ServerOn : IHTTP.ServerOn
{
public EventHandler OnClose { get; private set; }
public EventHandler<Exception> OnError { get; private set; }
public EventHandler<HttpListener> OnModify { get; private set; }
public EventHandler OnOpen { get; private set; }
public EventHandler OnClose { get; private set; }
public EventHandler<Exception> OnError { get; private set; }
public EventHandler<HttpListener> OnModify { get; private set; }
public EventHandler OnOpen { get; private set; }

public void Open(Action callback)
{
OnOpen += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke());
}
public void Open(Action callback)
{
OnOpen += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke());
}

public void Error(Action<Exception> callback)
{
OnError += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke(@event));
}
public void Error(Action<Exception> callback)
{
OnError += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke(@event));
}

public void Close(Action callback)
{
OnClose += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke());
}
public void Close(Action callback)
{
OnClose += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke());
}

public void Modify(Action<HttpListener> callback)
{
OnModify += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke(@event));
}
public void Modify(Action<HttpListener> callback)
{
OnModify += (@object, @event) => Env.MainThread.Add(() => callback?.Invoke(@event));
}
}
}
Expand Down

0 comments on commit 128a938

Please sign in to comment.