Пример #1
0
        public IPCClient(bool autoReconnect = false)
        {
            logger   = LoggerUtil.GetAppWideLogger();
            ipcQueue = new IPCMessageTracker(this);

            var channel = string.Format("{0}.{1}", nameof(Citadel.IPC), FingerprintService.Default.Value2).ToLower();

            client = PlatformTypes.New <IPipeClient>(channel, autoReconnect); // new NamedPipeClient<BaseMessage>(channel);

            logger.Info("Process {0} creating client", Process.GetCurrentProcess().Id);

            client.Connected     += OnConnected;
            client.Disconnected  += OnDisconnected;
            client.ServerMessage += OnServerMessage;
            client.AutoReconnect  = autoReconnect;

            client.Error += clientError;

            client.Start();

            m_callbacks.Add(typeof(IpcMessage), (msg) =>
            {
                HandleIpcMessage(msg as IpcMessage);
            });
        }
Пример #2
0
        /// <summary>
        /// Constructs a new named pipe server for IPC, with a channel name derived from the class
        /// namespace and the current machine's digital fingerprint.
        /// </summary>
        public IPCServer()
        {
            m_logger = LoggerUtil.GetAppWideLogger();

            var channel = string.Format("{0}.{1}", nameof(Citadel.IPC), FingerprintService.Default.Value2).ToLower();

            m_server = PlatformTypes.New <IPipeServer>(channel);

            //m_server = new NamedPipeServer<BaseMessage>(channel, security);

            m_server.ClientConnected    += OnClientConnected;
            m_server.ClientDisconnected += OnClientDisconnected;
            m_server.ClientMessage      += OnClientMessage;

            m_server.Error += M_server_Error;

            // Server is no longer started by constructor. We start the IPCServer after everything else has been set up by the FilterServiceProvider.
            m_ipcQueue = new IPCMessageTracker(this);

            m_callbacks.Add(typeof(AddSelfModerationEntryMessage), (msg) =>
            {
                AddSelfModerationEntry?.Invoke(msg as AddSelfModerationEntryMessage);
            });

            m_callbacks.Add(typeof(IpcMessage), (msg) =>
            {
                // The new IPC message Request/Send API handles
                HandleIpcMessage(msg);
            });
        }
Пример #3
0
        public IPCClient(bool autoReconnect = false)
        {
            m_logger = LoggerUtil.GetAppWideLogger();

            var channel = string.Format("{0}.{1}", nameof(Citadel.IPC), FingerPrint.Value).ToLower();

            m_logger.Info("Creating client.");

            m_client = new NamedPipeClient <BaseMessage>(channel);

            m_client.Connected     += OnConnected;
            m_client.Disconnected  += OnDisconnected;
            m_client.ServerMessage += OnServerMessage;
            m_client.AutoReconnect  = autoReconnect;

            m_client.Error += M_client_Error;

            m_client.Start();

            m_ipcQueue = new IPCMessageTracker();
        }
Пример #4
0
        /// <summary>
        /// Constructs a new named pipe server for IPC, with a channel name derived from the class
        /// namespace and the current machine's digital fingerprint.
        /// </summary>
        public IPCServer()
        {
            m_logger = LoggerUtil.GetAppWideLogger();

            var channel = string.Format("{0}.{1}", nameof(Citadel.IPC), FingerPrint.Value).ToLower();

            var security = GetSecurityForChannel();

            m_server = new NamedPipeServer <BaseMessage>(channel, security);

            m_server.ClientConnected    += OnClientConnected;
            m_server.ClientDisconnected += OnClientDisconnected;
            m_server.ClientMessage      += OnClientMessage;

            m_server.Error += M_server_Error;

            m_server.Start();

            m_ipcQueue = new IPCMessageTracker();

            m_logger.Info("IPC Server started.");
        }