Append method 'RegisterInboxIfNoExists' in server methods.
pull/1/head
a.bozhenov 5 years ago
parent b9eb1de8a9
commit 90cb844e52

@ -9,10 +9,13 @@ namespace ZeroLevel.Network
#region Messages
IServer RegisterInbox(string inbox, MessageHandler handler);
IServer RegisterInbox<T>(string inbox, MessageHandler<T> handler);
// Default inboxe
IServer RegisterInbox(MessageHandler handler);
IServer RegisterInbox<T>(MessageHandler<T> handler);
IServer RegisterInboxIfNoExists(string inbox, MessageHandler handler);
IServer RegisterInboxIfNoExists<T>(string inbox, MessageHandler<T> handler);
IServer RegisterInboxIfNoExists(MessageHandler handler);
IServer RegisterInboxIfNoExists<T>(MessageHandler<T> handler);
#endregion
#region Requests

@ -142,9 +142,14 @@ namespace ZeroLevel.Network
public void HandleRequest(Frame frame, ISocketClient client, int identity, Action<int, byte[]> handler) => _router.HandleRequest(frame, client, identity, handler);
public IServer RegisterInbox(string inbox, MessageHandler handler) => _router.RegisterInbox(inbox, handler);
public IServer RegisterInbox(MessageHandler handler) => _router.RegisterInbox(handler);
public IServer RegisterInbox<T>(string inbox, MessageHandler<T> handler) => _router.RegisterInbox<T>(inbox, handler);
public IServer RegisterInbox<T>(MessageHandler<T> handler) => _router.RegisterInbox<T>(handler);
public IServer RegisterInboxIfNoExists(string inbox, MessageHandler handler) => _router.RegisterInboxIfNoExists(inbox, handler);
public IServer RegisterInboxIfNoExists(MessageHandler handler) => _router.RegisterInboxIfNoExists(handler);
public IServer RegisterInboxIfNoExists<T>(string inbox, MessageHandler<T> handler) => _router.RegisterInboxIfNoExists<T>(inbox, handler);
public IServer RegisterInboxIfNoExists<T>(MessageHandler<T> handler) => _router.RegisterInboxIfNoExists<T>(handler);
public IServer RegisterInbox<Tresponse>(string inbox, RequestHandler<Tresponse> handler) => _router.RegisterInbox<Tresponse>(inbox, handler);
public IServer RegisterInbox<Trequest, Tresponse>(string inbox, RequestHandler<Trequest, Tresponse> handler) => _router.RegisterInbox<Trequest, Tresponse>(inbox, handler);
public IServer RegisterInbox<Tresponse>(RequestHandler<Tresponse> handler) => _router.RegisterInbox<Tresponse>(handler);

@ -320,6 +320,46 @@ namespace ZeroLevel.Network
_handlers[BaseSocket.DEFAULT_MESSAGE_INBOX].Add(MRInvoker.Create<T>(handler));
return this;
}
public IServer RegisterInboxIfNoExists(string inbox, MessageHandler handler)
{
if (false == _handlers.ContainsKey(inbox))
{
_handlers.Add(inbox, new List<MRInvoker>());
_handlers[inbox].Add(MRInvoker.Create(handler));
}
return this;
}
public IServer RegisterInboxIfNoExists<T>(string inbox, MessageHandler<T> handler)
{
if (false == _handlers.ContainsKey(inbox))
{
_handlers.Add(inbox, new List<MRInvoker>());
_handlers[inbox].Add(MRInvoker.Create<T>(handler));
}
return this;
}
public IServer RegisterInboxIfNoExists(MessageHandler handler)
{
if (false == _handlers.ContainsKey(BaseSocket.DEFAULT_MESSAGE_INBOX))
{
_handlers.Add(BaseSocket.DEFAULT_MESSAGE_INBOX, new List<MRInvoker>());
_handlers[BaseSocket.DEFAULT_MESSAGE_INBOX].Add(MRInvoker.Create(handler));
}
return this;
}
public IServer RegisterInboxIfNoExists<T>(MessageHandler<T> handler)
{
if (false == _handlers.ContainsKey(BaseSocket.DEFAULT_MESSAGE_INBOX))
{
_handlers.Add(BaseSocket.DEFAULT_MESSAGE_INBOX, new List<MRInvoker>());
_handlers[BaseSocket.DEFAULT_MESSAGE_INBOX].Add(MRInvoker.Create<T>(handler));
}
return this;
}
#endregion
#region Request handlers registration
@ -405,6 +445,10 @@ namespace ZeroLevel.Network
public IServer RegisterInbox<T>(string inbox, MessageHandler<T> handler) { return this; }
public IServer RegisterInbox(MessageHandler handler) { return this; }
public IServer RegisterInbox<T>(MessageHandler<T> handler) { return this; }
public IServer RegisterInboxIfNoExists(string inbox, MessageHandler handler) { return this; }
public IServer RegisterInboxIfNoExists<T>(string inbox, MessageHandler<T> handler) { return this; }
public IServer RegisterInboxIfNoExists(MessageHandler handler) { return this; }
public IServer RegisterInboxIfNoExists<T>(MessageHandler<T> handler) { return this; }
public IServer RegisterInbox<Tresponse>(string inbox, RequestHandler<Tresponse> handler) { return this; }
public IServer RegisterInbox<Trequest, Tresponse>(string inbox, RequestHandler<Trequest, Tresponse> handler) { return this; }
public IServer RegisterInbox<Tresponse>(RequestHandler<Tresponse> handler) { return this; }

Loading…
Cancel
Save

Powered by TurnKey Linux.