1234567891011121314151617181920212223242526272829303132333435363738 |
- using InABox.Clients;
- using InABox.Core;
- using InABox.IPC.Shared;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace InABox.Client.IPC
- {
- public static class IPCClientFactory
- {
- private static Dictionary<string, IPCClient> Clients = new();
- public static IPCClient GetClient(string pipeName)
- {
- if (!Clients.TryGetValue(pipeName, out var client))
- {
- client = new IPCClient(pipeName);
- Clients[pipeName] = client;
- client.OnPush += Client_OnPush;
- }
- return client;
- }
- private static void Client_OnPush(PipeRequest request)
- {
- if(request.Method == Method.Notification)
- {
- if(request.Type is not null && CoreUtils.TryGetEntity(request.Type, out var entity))
- {
- ClientFactory.Notifications.Notify(entity, Serialization.Deserialize(entity, request.Data));
- }
- }
- }
- }
- }
|