public virtual CommandResponse ParseResponse(string line) { lock (this.SyncLock) { int x; string s; string responseType; string responseTupleString; CommandResponse retval; s = line; x = s.IndexOf(' '); if (x < 0) { responseType = s; responseTupleString = ""; } else { responseType = s.Substring(0, x); responseTupleString = s.Substring(x + 1); } if (responseType.EqualsIgnoreCase(ResponseCodes.OK) || responseType.EqualsIgnoreCase(ResponseCodes.ERROR)) { retval = new CommandResponse(responseType, responseTupleString); } else { throw new RemoteVirtualFileSystemException(ErrorCodes.UNEXPECTED); } return retval; } }
public override void Write(byte[] buffer, int offset, int count) { StabilizeClientState(true); lock (this.client.SyncLock) { this.client.SendCommandWithoutResponse("write {0}", count); this.client.WriteStream.Write(buffer, offset, count); //client.WriteStream.Flush(); } var dateTime = DateTime.Now; this.writeResponsesQueue.Enqueue(delegate { //lock (writeResponsesQueue.SyncLock) { var response = this.client.ReadResponse(); this.client.ReadReady(); if (response.ResponseType != ResponseCodes.OK) { if (this.errorResponse != null) { this.errorResponse = response; } } else if (this.writeResponsesQueue.Count == 0) { var now = DateTime.Now; if (now < dateTime || (now - dateTime > TimeSpan.FromSeconds(60))) { this.writeResponsesQueue.Stop(); } } } }); if (this.writeResponsesQueue.TaskState != TaskState.Running && this.writeResponsesQueue.Count > 0) { this.writeResponsesQueue.TaskAsynchronisity = TaskAsynchronisity.AsyncWithSystemPoolThread; this.writeResponsesQueue.Start(); } this.position += count; if (this.position > this.length) { this.length = this.position; } }