protected bool WriteData(byte[] data, int offset, int count) { //byte[] messageData = null; //if (offset == 0 && data.Length == count) //{ // messageData = data; //} //else //{ // messageData = new byte[count]; // Buffer.BlockCopy(data, offset, messageData, 0, count); //} lock (_sendBuffer) { ArraySegment <byte> packetData = _packetSpliter.MakePacket(data, offset, count, _sendBuffer); int curDataLength = GetDataLength(); int curPosition = curDataLength + 4; if (WriteDataRaw(curPosition, packetData.Array, offset, packetData.Count)) { curDataLength += packetData.Count; WriteDataLength(curDataLength); return(true); } return(false); } }
public void SendMessage(byte[] messageData, int offset, int count) { if (!_isRunning) { throw new NotRunningException("the pipe is not running"); } if (_pipeStream.IsConnected) { byte[] dataPacket = _packetSpliter.MakePacket(messageData, offset, count); _pipeStream.Write(dataPacket, 0, dataPacket.Length); } }
public void SendMessage(byte[] messageData, int offset, int count) { if (!_isRunning) { throw new NotRunningException("the pipe is not running"); } if (_pipeStream.IsConnected) { ArraySegment <byte> dataPacket = _packetSpliter.MakePacket(messageData, offset, count, _sendBuffer); _pipeStream.Write(dataPacket.Array, dataPacket.Offset, dataPacket.Count); } }
protected bool WriteData(byte[] data, int offset, int count) { byte[] messageData = null; if (offset == 0 && data.Length == count) { messageData = data; } else { messageData = new byte[count]; Array.Copy(data, offset, messageData, 0, count); } byte[] packetData = _packetSpliter.MakePacket(data, offset, count); int curDataLength = GetDataLength(); int curPosition = curDataLength + 4; if (WriteDataRaw(curPosition, packetData, offset, packetData.Length)) { curDataLength += packetData.Length; WriteDataLength(curDataLength); return(true); } return(false); }