public static IDataSet Read(string ipAddress, int port, string dataBase, string tags, string filterExpression, bool isDevmode) { if (dataBase == null) { throw new ArgumentNullException("database"); } if (tags == null) { throw new ArgumentNullException("tags"); } if (filterExpression == null) { throw new ArgumentNullException("filterExpression"); } var dic = new Dictionary <string, object>(); dic.Add("type", "bin"); dic.Add("tags", tags); dic.Add("database", dataBase); dic.Add("devmode", isDevmode); if (filterExpression != string.Empty) { dic.Add("filter", filterExpression); } var items = dic.Select(i => string.Format("{0}=\"{1}\"", i.Key, i.Value)).ToArray(); var name = string.Join(";", items); using (var stream = new RemoteStream(ipAddress, port + 1, name)) { return(CremaReader.Read(stream)); } }
async private Task ReadContent() { if (_responseInspector != null) { _responseInspector.OnResponseBodyProgress(); } long contentLength; if (!long.TryParse(Prologue.Headers.FirstOrDefault(x => x.Key == "Content-Length").Value, out contentLength)) { contentLength = -1; } //Debug.WriteLine("Reader Server Response Content"); var content = new MemoryStream(); await RemoteStream.CopyHttpMessageToAsync(RemoteSocket, content, contentLength); if (content.Length != 0) { content.Position = 0; Content = content; } //Debug.WriteLine("Reader Server Response Content - DONE"); if (_responseInspector != null) { _responseInspector.OnResponseBodyReceived(); } }
void RemoteQueue_Process(object sender, ProcessQueueEventArgs <Tuple <byte[], int, int> > e) { var ar = RemoteStream.BeginWrite(e.Item.Item1, e.Item.Item2, e.Item.Item3, null, null); using (ar.AsyncWaitHandle) { if (ar.AsyncWaitHandle.WaitOne(-1)) { RemoteStream.EndWrite(ar); } } }
protected virtual void End() { RemoteStream.Close(); RemoteSocket.Shutdown(SocketShutdown.Both); RemoteSocket.Close(); ClientStream.Close(); ClientSocket.Shutdown(SocketShutdown.Both); ClientSocket.Close(); }
public virtual void Start(string remote, int remoteport) { try { ConnectRemote(remote, remoteport); Host.OnConnect(this); SourceStream.BeginRead(SourceBuffer, 0, BufferSize, BeginReceive, SourceStream); RemoteStream.BeginRead(RemoteBuffer, 0, BufferSize, BeginReceive, RemoteStream); } catch (Exception ex) { Host.OnException(this, ex); } }