Esempio n. 1
0
        /// <summary>
        /// INTERNAL METHOD. Developers do not call!
        /// This constructor is used by a synchronous binding that delivers response right after sending it.
        /// ONLY for OneWayCall = false
        /// </summary>
        public CallSlot(ClientEndPoint client,
                        ClientTransport clientTransport,
                        long actualStartTimeTicks,
                        DateTime actualStartTimeUtc,
                        RequestMsg request,
                        ResponseMsg response,
                        int timeoutMs)
        {
            m_Client          = client;
            m_ClientTransport = clientTransport;
            m_RequestID       = request.RequestID;
            m_OneWay          = false;
            m_StartTime       = actualStartTimeUtc;
            m_TimeoutMs       = timeoutMs > 0 ? timeoutMs : DEFAULT_TIMEOUT_MS;

            if (client.Binding.MeasureStatTimes)
            {
                m_StatStartTimeTicks   = actualStartTimeTicks;
                m_StatRoundtripTimeKey = client.Binding.GetClientCallStatTimeKey(client, request);
            }

            m_ResponseMsg = response;
            m_CallStatus  = m_ResponseMsg.OK ? CallStatus.ResponseOK : CallStatus.ResponseError;
            var remoteInstance = response.RemoteInstance;

            if (remoteInstance.HasValue)
            {
                m_Client.__setRemoteInstance(remoteInstance.Value);
            }

            if (m_StatRoundtripTimeKey != null && m_Client.Binding.MeasureStatTimes)
            {
                m_StatRoundtripEndTimeTicks = m_Client.Binding.StatTimeTicks;
                m_ClientTransport.stat_Time(m_StatRoundtripTimeKey, m_StatRoundtripEndTimeTicks - m_StatStartTimeTicks);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Called internally by framework to populate the response message when one asynchronously arrives from transport
        /// </summary>
        internal void DeliverResponse(ResponseMsg response)
        {
            lock (m_Sync)
            {
                m_ResponseMsg = response;
                m_CallStatus  = m_ResponseMsg.OK ? CallStatus.ResponseOK : CallStatus.ResponseError;

                var remoteInstance = response.RemoteInstance;
                if (remoteInstance.HasValue)
                {
                    m_Client.__setRemoteInstance(remoteInstance.Value);
                }

                if (m_StatRoundtripTimeKey != null && m_Client.Binding.MeasureStatTimes)
                {
                    m_StatRoundtripEndTimeTicks = m_Client.Binding.StatTimeTicks;
                    m_ClientTransport.stat_Time(m_StatRoundtripTimeKey, m_StatRoundtripEndTimeTicks - m_StatStartTimeTicks);
                }

                Monitor.Pulse(m_Sync);

                completePendingTask();//result arrived - normal case
            }
        }