Ejemplo n.º 1
0
        /// <inheritdoc />
        public async Task <IpcBufferMessage> GetResponseAsync(IpcRequestMessage request)
        {
            var ipcClientRequestMessage = IpcMessageRequestManager.CreateRequestMessage(request);
            await IpcClientService.WriteMessageAsync(ipcClientRequestMessage.IpcBufferMessageContext);

            return(await ipcClientRequestMessage.Task);
        }
Ejemplo n.º 2
0
        private void OnPeerConnectionBroken(IPeerConnectionBrokenArgs e)
        {
            IsBroken = true;
            IpcClientService.Dispose();

            PeerConnectionBroken?.Invoke(this, e);
        }
Ejemplo n.º 3
0
        internal PeerProxy(string peerName, IpcClientService ipcClientService, IpcContext ipcContext)
        {
            PeerName         = peerName;
            IpcClientService = ipcClientService;
            IpcMessageWriter = new IpcMessageWriter(ipcClientService);

            IpcContext = ipcContext;

            IpcMessageRequestManager = new IpcMessageRequestManager();
            IpcMessageRequestManager.OnIpcClientRequestReceived += ResponseManager_OnIpcClientRequestReceived;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 连接其他客户端
        /// </summary>
        /// <param name="peerName">对方</param>
        /// <returns></returns>
        public async Task <IpcClientService> ConnectPeer(string peerName)
        {
            if (ConnectedServerManagerList.TryGetValue(peerName, out var ipcClientService))
            {
            }
            else
            {
                // 这里无视多次加入,这里的多线程问题也可以忽略

                var task = StartServer();

                ipcClientService = new IpcClientService(IpcContext, peerName);

                if (ConnectedServerManagerList.TryAdd(peerName, ipcClientService))
                {
                }

                await ipcClientService.Start();

                await task;
            }

            return(ipcClientService);
        }
Ejemplo n.º 5
0
 internal PeerProxy(string peerName, IpcClientService ipcClientService, IpcInternalPeerConnectedArgs ipcInternalPeerConnectedArgs, IpcContext ipcContext) :
     this(peerName, ipcClientService, ipcContext)
 {
     Update(ipcInternalPeerConnectedArgs);
 }