bool UpdateStream(out UInt16 flag, out ViIStream IS) { flag = 0; IS = null; NetworkStream stream = _client.GetStream(); if (_receiver.Size == 0) { if (_client.Available < RECEIVE_HEAD_SIZE) { return(false); } SetConnectState(true); int bufferSize = stream.Read(_receiveHead, 0, RECEIVE_HEAD_SIZE); UInt16 flag_ = ViBitConverter.ToUInt16(_receiveHead, 0); UInt32 size = ViBitConverter.ToUInt32(_receiveHead, RECEIVE_SIZE_OFFSET); _receiver.SetCompleteSize(flag_, size); } _receiver.Read(stream); if (_receiver.IsComplete == false) { return(false); } _IS.Init(_receiver.Data, _receiver.Size); _receiver.Clear(); IS = _IS; return(true); }
public bool Read(out string value) { if (_offset + 1 > _len) { ViDebuger.Warning("Read Fail string"); value = string.Empty; _offset = _len; return(false); } Int32 len = ViBitConverter.ToUInt8(_buffer, _offset); _offset += 1; if (len == 255) { if (_offset + 2 > _len) { ViDebuger.Warning("Read Fail string"); value = string.Empty; _offset = _len; return(false); } len = ViBitConverter.ToUInt16(_buffer, _offset); _offset += 2; } value = ViBitConverter.ToString(_buffer, _offset, len); _Print("string", value); _offset += len; return(true); }
public bool Read(out UInt16 value) { if (_offset + 2 > _len) { ViDebuger.Warning("Read Fail UInt16"); value = (UInt16)0; _offset = _len; return(false); } value = ViBitConverter.ToUInt16(_buffer, _offset); _Print("UInt16", value); _offset += 2; return(true); }