Refine Service Api a bit

This commit is contained in:
K35
2022-01-07 22:10:24 +00:00
parent bb46da08de
commit 48a0713045
5 changed files with 19 additions and 4 deletions

View File

@ -16,9 +16,9 @@ public class JRpcServer<TContext>
this.Services = new Dictionary<string, JRpcService<TContext>>();
}
public void AddService(string name, JRpcService<TContext> service)
public void AddService(JRpcService<TContext> service)
{
this.Services.Add(name, service);
this.Services.Add(service.Name, service);
}
public JRpcServerSession<TContext> GetSession(JRpcTransport transport, TContext context)
@ -184,8 +184,11 @@ public class JRpcServerSession<TContext>
public abstract class JRpcService<TContext>
{
public abstract string Name { get; }
public HashSet<string> Functions = new HashSet<string>();
protected void RegisterFunction(string name)
{
this.Functions.Add(name);