示例#1
0
        /// <summary>
        /// Called when the base class receives a LillTek duplex session connection
        /// attempt from the router.  Session oriented derived  classes must implement
        /// this to accept a new channel or route the message to an existing channel.
        /// </summary>
        /// <param name="msg">The session opening <see cref="DuplexSessionMsg" />.</param>
        protected override void OnSessionConnect(DuplexSessionMsg msg)
        {
            InputSessionChannel newChannel = null;
            string sessionID = msg._SessionID.ToString("D");

            if (base.State != CommunicationState.Opened)
            {
                return;
            }

            using (TimedLock.Lock(this))
            {
                // Ignore session create messages that may to an existing channel.

                if (base.Channels.ContainsKey(sessionID))
                {
                    return;
                }

                // Create a new channel for the session.

                newChannel = new InputSessionChannel(this, new EndpointAddress(this.Uri), sessionID, msg.Session);
                AddChannel(newChannel);
            }

            // Do this outside of the lock just to be safe

            if (newChannel != null)
            {
                base.OnChannelCreated(newChannel);
            }
        }
示例#2
0
        /// <summary>
        /// Called when the message router receives a LillTek message.
        /// </summary>
        /// <param name="msg">The received message.</param>
        private void OnReceive(Msg msg)
        {
            try
            {
                if (sessionMode)
                {
                    DuplexSessionMsg duplexMsg = msg as DuplexSessionMsg;

                    // Handle client session connection attempts.

                    if (duplexMsg != null)
                    {
                        OnSessionConnect(duplexMsg);
                        return;
                    }
                }
                else
                {
                    // Handle encapsulated WCF messages.

                    WcfEnvelopeMsg envelopeMsg = msg as WcfEnvelopeMsg;
                    Message        message;

                    if (envelopeMsg == null)
                    {
                        return;     // Discard non-envelope messages
                    }
                    message = DecodeMessage(envelopeMsg);

                    // Let the derived listener decide what to do with the message.

                    OnMessageReceived(message, envelopeMsg);
                }
            }
            catch (Exception e)
            {
                SysLog.LogException(e);
            }
        }
示例#3
0
 /// <summary>
 /// Called when the base class receives a LillTek duplex session connection
 /// attempt from the router.  Session oriented derived  classes must implement
 /// this to accept a new channel or route the message to an existing channel.
 /// </summary>
 /// <param name="msg">The session opening <see cref="DuplexSessionMsg" />.</param>
 protected abstract void OnSessionConnect(DuplexSessionMsg msg);
示例#4
0
 /// <summary>
 /// Called when the base class receives a LillTek duplex session connection
 /// attempt from the router.  Session oriented derived  classes must implement
 /// this to accept a new channel or route the message to an existing channel.
 /// </summary>
 /// <param name="msg">The session opening <see cref="DuplexSessionMsg" />.</param>
 protected override void OnSessionConnect(DuplexSessionMsg msg)
 {
     throw new InvalidOperationException();
 }
示例#5
0
 /// <summary>
 /// Called when the base class receives a LillTek duplex session connection
 /// attempt from the router.  Session oriented derived  classes must implement
 /// this to accept a new channel or route the message to an existing channel.
 /// </summary>
 /// <param name="msg">The session opening <see cref="DuplexSessionMsg" />.</param>
 protected override void OnSessionConnect(DuplexSessionMsg msg)
 {
 }