Example #1
0
        private CallSlot sendRequest(ClientEndPoint endpoint, RequestMsg request, CallOptions options)
        {
            if (m_PriorDispatchTimeoutMs != options.DispatchTimeoutMs)
            {
                m_Client.Socket.SendTimeout = options.DispatchTimeoutMs;
                m_PriorDispatchTimeoutMs    = options.DispatchTimeoutMs;
            }

            if (m_PriorTimeoutMs != options.TimeoutMs)
            {
                m_Client.Socket.ReceiveTimeout = options.TimeoutMs;
                m_PriorTimeoutMs = options.TimeoutMs;
            }


            var chunk = m_Client.GetSendChunk();

            try
            {
                var frame = new WireFrame(WireFrame.SLIM_FORMAT, request.OneWay, request.RequestID);
                var size  = serialize(chunk, frame, request);
                var wm    = new WireMsg(chunk);


                Binding.DumpMsg(false, request, chunk.GetBuffer(), 0, (int)chunk.Position);

                if (size > Binding.MaxMsgSize)
                {
                    Instrumentation.ClientSerializedOverMaxMsgSizeErrorEvent.Happened(App.Instrumentation, Node);
                    throw new MessageSizeException(size, Binding.MaxMsgSize, "sendRequest(" + request.RequestID + ")");
                }

                m_Client.Send(wm);

                stat_MsgSent();
                stat_BytesSent(wm.BufferUsedSize);
            }
            catch
            {
                stat_Errors();
                throw;
            }
            finally
            {
                m_Client.ReleaseSendChunk();
            }


            //regardless of (request.OneWay) we return callslot anyway
            return(new CallSlot(endpoint, this, request, CallStatus.Dispatched, options.TimeoutMs));
        }