Ejemplo n.º 1
0
        ///// <summary>
        ///// 当断开连接的时候触发
        ///// </summary>
        //public event EventHandler<PeerProxy>? Disconnected;

        internal void Update(IpcInternalPeerConnectedArgs ipcInternalPeerConnectedArgs)
        {
            Debug.Assert(ipcInternalPeerConnectedArgs.PeerName == PeerName);

            var serverStreamMessageReader = ipcInternalPeerConnectedArgs.ServerStreamMessageReader;

            serverStreamMessageReader.MessageReceived -= ServerStreamMessageReader_MessageReceived;
            serverStreamMessageReader.MessageReceived += ServerStreamMessageReader_MessageReceived;

            // 连接断开
            serverStreamMessageReader.PeerConnectBroke -= ServerStreamMessageReader_PeerConnectBroke;
            serverStreamMessageReader.PeerConnectBroke += ServerStreamMessageReader_PeerConnectBroke;

            IsConnectedFinished = true;

            if (WaitForFinishedTaskCompletionSource.TrySetResult(true))
            {
            }
            else
            {
                Debug.Assert(false, "重复调用");
            }
        }
Ejemplo n.º 2
0
 internal PeerProxy(string peerName, IpcClientService ipcClientService, IpcInternalPeerConnectedArgs ipcInternalPeerConnectedArgs, IpcContext ipcContext) :
     this(peerName, ipcClientService, ipcContext)
 {
     Update(ipcInternalPeerConnectedArgs);
 }
        internal void OnPeerConnected(object?sender, IpcInternalPeerConnectedArgs e)
        {
            Logger.Debug($"[{nameof(IpcServerService)}] PeerConnected PeerName={e.PeerName} {e.Ack}");

            PeerConnected?.Invoke(sender, e);
        }