コード例 #1
0
 protected void SendFault(string faultString, TimeSpan timeout)
 {
     byte[] drainBuffer = new byte[128];
     InitialServerConnectionReader.SendFault(
         connection, faultString, drainBuffer, timeout,
         TransportDefaults.MaxDrainSize);
 }
コード例 #2
0
 public void SendFault(string faultString)
 {
     InitialServerConnectionReader.SendFault(
         Connection, faultString, connectionBuffer, GetRemainingTimeout(),
         TransportDefaults.MaxDrainSize);
     base.Close(GetRemainingTimeout());
 }
コード例 #3
0
 void SendFault(string faultString, ref TimeoutHelper timeoutHelper)
 {
     InitialServerConnectionReader.SendFault(Connection, faultString,
                                             connectionBuffer, timeoutHelper.RemainingTime(), TransportDefaults.MaxDrainSize);
 }
コード例 #4
0
        bool ContinueReading()
        {
            for (;;)
            {
                if (size == 0)
                {
                    if (readCallback == null)
                    {
                        readCallback = ReadCallback;
                    }

                    if (Connection.BeginRead(0, Connection.AsyncReadBufferSize, GetRemainingTimeout(),
                                             readCallback, this) == AsyncCompletionResult.Queued)
                    {
                        break;
                    }
                    if (!GetReadResult()) // we're at EOF, bail
                    {
                        return(false);
                    }
                }

                for (;;)
                {
                    int bytesDecoded;
                    try
                    {
                        bytesDecoded = decoder.Decode(buffer, offset, size);
                    }
                    catch (CommunicationException e)
                    {
                        // see if we need to send back a framing fault
                        string framingFault;
                        if (FramingEncodingString.TryGetFaultString(e, out framingFault))
                        {
                            byte[] drainBuffer = new byte[128];
                            InitialServerConnectionReader.SendFault(
                                Connection, framingFault, drainBuffer, GetRemainingTimeout(),
                                MaxViaSize + MaxContentTypeSize);
                            base.Close(GetRemainingTimeout());
                        }
                        throw;
                    }

                    if (bytesDecoded > 0)
                    {
                        offset += bytesDecoded;
                        size   -= bytesDecoded;
                    }
                    if (decoder.CurrentState == ServerModeDecoder.State.Done)
                    {
                        return(true);
                    }
                    if (size == 0)
                    {
                        break;
                    }
                }
            }

            return(false);
        }