コード例 #1
0
        private void OnTransportShutdownCompleted(ShutdownCompletedEventArgs e)
        {
            var handler = this.TransportShutdownCompleted;

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #2
0
        /// <summary>
        ///		Raises <see cref="ShutdownCompleted"/> event.
        /// </summary>
        /// <param name="e">The <see cref="ShutdownCompletedEventArgs"/> instance containing the event data.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="e"/> is <c>null</c>.
        /// </exception>
        protected virtual void OnShutdownCompleted(ShutdownCompletedEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            Contract.EndContractBlock();

            Interlocked.CompareExchange(ref shutdownCompleted, null, null)?.Invoke(this, e);
            Interlocked.Exchange(ref isInShutdown, 0);
        }
コード例 #3
0
        void OnTransportShutdownCompleted(object sender, ShutdownCompletedEventArgs e)
        {
            var transport = sender as TTransport;

            Contract.Assert(transport != null);
            try { }
            finally {
                transport.ShutdownCompleted -= OnTransportShutdownCompleted;
                if (Interlocked.Decrement(ref tranportIsInShutdown) == 0)
                {
                    OnShutdownCompleted(e);
                }
            }
        }
コード例 #4
0
        /// <summary>
        ///		Raises internal shutdown completion routine.
        /// </summary>
        /// <param name="e">The <see cref="MsgPack.Rpc.Protocols.ShutdownCompletedEventArgs"/> instance containing the event data.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="e"/> is <c>null</c>.
        /// </exception>
        protected virtual void OnShutdownCompleted(ShutdownCompletedEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            Contract.EndContractBlock();

            var socket = Interlocked.Exchange(ref this._boundSocket, null);

            MsgPackRpcClientProtocolsTrace.TraceEvent(
                MsgPackRpcClientProtocolsTrace.TransportShutdownCompleted,
                "Transport shutdown is completed. {{ \"Socket\" : 0x{0:X}, \"RemoteEndPoint\" : \"{1}\", \"LocalEndPoint\" : \"{2}\" }}",
                GetHandle(socket),
                GetRemoteEndPoint(socket, default(MessageContext)),
                GetLocalEndPoint(socket)
                );

            if (socket != null)
            {
                socket.Close();
            }

            // Notify shutdown to waiting clients.
            // Note that it is OK from concurrency point of view because additional modifications are guarded via shutdown flag.
            var errorMessage = new RpcErrorMessage(RpcError.TransportError, String.Format(CultureInfo.CurrentCulture, "Transport is shutdown. Shutdown source is: {0}", e.Source), null);

            foreach (var entry in this._pendingRequestTable)
            {
                entry.Value(null, errorMessage.ToException(), false);
            }

            foreach (var entry in this._pendingNotificationTable)
            {
                entry.Value(errorMessage.ToException(), false);
            }

            this._pendingRequestTable.Clear();
            this._pendingNotificationTable.Clear();

            var handler = Interlocked.CompareExchange(ref this._shutdownCompleted, null, null);

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #5
0
        /// <summary>
        ///		Raises <see cref="ShutdownCompleted"/> event.
        /// </summary>
        /// <param name="e">The <see cref="MsgPack.Rpc.Protocols.ShutdownCompletedEventArgs"/> instance containing the event data.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="e"/> is <c>null</c>.
        /// </exception>
        protected virtual void OnShutdownCompleted(ShutdownCompletedEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            Contract.EndContractBlock();

            var handler = Interlocked.CompareExchange(ref this._shutdownCompleted, null, null);

            if (handler != null)
            {
                handler(this, e);
            }

            Interlocked.Exchange(ref this._isInShutdown, 0);
        }
コード例 #6
0
        /// <summary>
        ///		Raises <see cref="ShutdownCompleted"/> event.
        /// </summary>
        /// <param name="e">The <see cref="MsgPack.Rpc.Protocols.ShutdownCompletedEventArgs"/> instance containing the event data.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="e"/> is <c>null</c>.
        /// </exception>
        protected virtual void OnShutdownCompleted(ShutdownCompletedEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            Contract.EndContractBlock();

            MsgPackRpcServerProtocolsTrace.TraceEvent(
                MsgPackRpcServerProtocolsTrace.ManagerShutdownCompleted,
                "Manager shutdown is completed. {{ \"Manager\" : \"{0}\" }}",
                this
                );

            var handler = Interlocked.CompareExchange(ref this._shutdownCompleted, null, null);

            if (handler != null)
            {
                handler(this, e);
            }
        }
コード例 #7
0
 private void OnTransportShutdownCompleted(object sender, ShutdownCompletedEventArgs e)
 {
     this.OnTransportShutdownCompleted(e);
 }