本文整理汇总了C#中ReadState类的典型用法代码示例。如果您正苦于以下问题:C# ReadState类的具体用法?C# ReadState怎么用?C# ReadState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReadState类属于命名空间,在下文中一共展示了ReadState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connection
internal Connection(System.Net.ConnectionGroup connectionGroup) : base(null)
{
this.m_IISVersion = -1;
this.m_Free = true;
this.m_Idle = true;
this.m_KeepAlive = true;
this.m_MaximumUnauthorizedUploadLength = SettingsSectionInternal.Section.MaximumUnauthorizedUploadLength;
if (this.m_MaximumUnauthorizedUploadLength > 0L)
{
this.m_MaximumUnauthorizedUploadLength *= 0x400L;
}
this.m_ResponseData = new CoreResponseData();
this.m_ConnectionGroup = connectionGroup;
this.m_ReadBuffer = new byte[0x1000];
this.m_ReadState = ReadState.Start;
this.m_WaitList = new List<WaitListItem>();
this.m_WriteList = new ArrayList();
this.m_AbortDelegate = new HttpAbortDelegate(this.AbortOrDisassociate);
this.m_ConnectionUnlock = new UnlockConnectionDelegate(this.UnlockRequest);
this.m_StatusLineValues = new StatusLineValues();
this.m_RecycleTimer = this.ConnectionGroup.ServicePoint.ConnectionLeaseTimerQueue.CreateTimer();
this.ConnectionGroup.Associate(this);
this.m_ReadDone = true;
this.m_WriteDone = true;
this.m_Error = WebExceptionStatus.Success;
}
示例2: ReadComplete
void ReadComplete( IAsyncResult iar )
{
int toread = 4;
int bytes = 0;
try
{
bytes = socket.EndReceive( iar );
}
catch( Exception )
{
socket.Close();
disconnected = true;
return;
}
switch( state )
{
case ReadState.readLength:
toread = BitConverter.ToInt32( buffer.GetBuffer(), 0 );
state = ReadState.readData;
break;
case ReadState.readData:
state = ReadState.readLength;
Protocol.Message msgId = (Protocol.Message)BitConverter.ToInt32( buffer.GetBuffer(), 0 );
switch( msgId )
{
default:
Log.log( "Received unhandled message: {0}", msgId );
break;
//case Protocol.Message.
}
break;
}
buffer.SetLength( toread );
socket.BeginReceive( buffer.GetBuffer(), 0, toread, SocketFlags.None, ReadComplete, null );
}
示例3: BeginRead
internal void BeginRead()
{
NetworkStream netstream = _tcp.GetStream();
int bufferSize = _tcp.ReceiveBufferSize;
var state = new ReadState(netstream, bufferSize);
netstream.BeginRead(state.Buffer, 0, state.Buffer.Length, ReadCallback, state);
}
示例4: Poll
public void Poll()
{
while (_stream.DataAvailable) {
switch (_readState) {
case ReadState.ReadLength:
_bufInt32Offset += _stream.Read(_bufInt32, _bufInt32Offset, 4 - _bufInt32Offset);
if (_bufInt32Offset == 4) {
_readState = ReadState.ReadType;
_bufInt32Offset = 0;
_intConverter.FromBytes(_bufInt32, 0);
_payload = new byte[_intConverter.intdata];
}
break;
case ReadState.ReadType:
_bufInt32Offset += _stream.Read (_bufInt32, _bufInt32Offset, 4 - _bufInt32Offset);
if (_bufInt32Offset == 4) {
_readState = ReadState.ReadPayload;
_bufInt32Offset = 0;
_intConverter.FromBytes(_bufInt32, 0);
_type = (PacketType)_intConverter.intdata;
}
break;
case ReadState.ReadPayload:
_payloadOffset += _stream.Read(_payload, _payloadOffset, _payload.Length - _payloadOffset);
if (_payloadOffset == _payload.Length) {
_readState = ReadState.ReadLength;
_payloadOffset = 0;
if (OnResponse != null) {
OnResponse(new Packet(){ type = _type, payload = _payload });
}
}
break;
}
}
}
示例5: CommState
internal CommState()
{
idle_tick = new Timer( CheckIdle, null, 30000, 30000 );
readstate = ReadState.getLength;
buffer = new MemoryStream( 1024 );
send_buffer = new MemoryStream( 1024 );
}
示例6: ChunkParser
public ChunkParser(Connection connection,ArraySegment<byte> initialBuffer, int initialBufferOffset, int initialBufferCount)
{
_connection = connection;
_buffer = initialBuffer;
_bufferCurrentPos = initialBufferOffset;
_bufferSize = initialBufferOffset + initialBufferCount;
_readState = ReadState.ChunkLength;
_currentChunkLength = -1;
}
示例7: Get
public RilList Get(ReadState state, DateTime? since, int? count, int? page, bool myAppOnly, bool tags)
{
var list = new RilList();
list.Items = new Dictionary<string, RilListItem>();
list.Items.Add("12345", new RilListItem() { Title = "Website 1", Url = "www.web1.com" });
list.Items.Add("23456", new RilListItem() { Title = "Website 2", Url = "www.web2.com" });
list.Items.Add("34567", new RilListItem() { Title = "Website 3", Url = "www.web3.com", Tags = "existing-tag" });
return list;
}
示例8: MasterServerConnection
internal MasterServerConnection( TcpClient client)
{
this.tcpClient = client;
socket = client.Client;
state = ReadState.readLength;
socket.NoDelay = true;
buffer.SetLength( 4 ); // makes ure buffer has a buffer
socket.BeginReceive( buffer.GetBuffer(), 0, 4, SocketFlags.None, ReadComplete, client );
SendHello();
}
示例9: TextIncludingReader
public TextIncludingReader(Uri includeLocation, string encoding,
string accept, string acceptLanguage, bool exposeCDATA) {
_includeLocation = includeLocation;
_href = includeLocation.AbsoluteUri;
_encoding = encoding;
_state = ReadState.Initial;
_accept = accept;
_acceptLanguage = acceptLanguage;
_exposeCDATA = exposeCDATA;
}
示例10: ResetForNewResponse
private void ResetForNewResponse()
{
if (_errorDecoder != null)
{
_errorDecoder.Dispose();
_errorDecoder = null;
}
_readState = new ReadState();
_currentReadState = ReadResponseHeader;
}
示例11: Read
internal static string Read(Record record, int lengthBits, ref int continueIndex, ref ushort offset)
{
string text = string.Empty;
ReadState state = new ReadState(record, lengthBits, continueIndex, offset);
Read(state);
continueIndex = state.ContinueIndex;
offset = state.Offset;
return new string(state.CharactersRead.ToArray());
}
示例12: Create
public static IHandler Create(WebSocketHttpRequest request, Action<string> onMessage, Action onClose)
{
var readState = new ReadState();
return new ComposableHandler
{
Handshake = () => Hybi13Handler.BuildHandshake(request),
Frame = s => Hybi13Handler.FrameData(Encoding.UTF8.GetBytes(s), FrameType.Text),
Close = i => Hybi13Handler.FrameData(i.ToBigEndianBytes<ushort>(), FrameType.Close),
RecieveData = d => Hybi13Handler.ReceiveData(d, readState, (op, data) => Hybi13Handler.ProcessFrame(op, data, onMessage, onClose))
};
}
示例13: Create
public static IHandler Create(WebSocketHttpRequest request, Action<string> onMessage, Fleck2Extensions.Action onClose, Action<byte[]> onBinary)
{
var readState = new ReadState();
return new ComposableHandler
{
Handshake = () => BuildHandshake(request),
TextFrame = data => FrameData(Encoding.UTF8.GetBytes(data), FrameType.Text),
BinaryFrame = data => FrameData(data, FrameType.Binary),
CloseFrame = i => FrameData(i.ToBigEndianBytes<ushort>(), FrameType.Close),
ReceiveData = bytes => ReceiveData(bytes, readState, (op, data) => ProcessFrame(op, data, onMessage, onClose, onBinary))
};
}
示例14: BufferEnd
private bool BufferEnd()
{
if (this.maxOffset != 0)
{
return false;
}
if ((this.readState != ReadState.ReadWS) && (this.readState != ReadState.ReadValue))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.Runtime.Serialization.SR.GetString("MimeReaderMalformedHeader")));
}
this.readState = ReadState.EOF;
return true;
}
示例15: XmlMicrodataReader
public XmlMicrodataReader(HtmlAgilityPack.HtmlNode rootEntity)
{
this.readState = System.Xml.ReadState.Initial;
this.rootEntity = new Item(rootEntity);
this.nodeType = XmlNodeType.None;
var typeAttr = rootEntity.GetAttributeItemType();
if (typeAttr != null)
{
Uri type;
Uri.TryCreate(typeAttr.Value, UriKind.Absolute, out type);
this.Type = type;
}
}