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

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

            PeerConnectionBroken?.Invoke(this, e);
        }
        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;
        }
示例#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);
        }
 internal PeerProxy(string peerName, IpcClientService ipcClientService, IpcInternalPeerConnectedArgs ipcInternalPeerConnectedArgs, IpcContext ipcContext) :
     this(peerName, ipcClientService, ipcContext)
 {
     Update(ipcInternalPeerConnectedArgs);
 }