public override long Send(IList <ILogEntity> logEntities) { if (logEntities == null || logEntities.Count <= 0) { return(0); } TLogPackage logPackage = this.CreateLogPackage(logEntities); var trans = new THttpClient(uri); trans.ConnectTimeout = SENDER_TIMEOUT; trans.DataSizeLimit = TransDataSizeLimit; //var protocol = new TBinaryProtocol(httpClient); var protocol = new TCompactProtocol(trans); trans.Open(); var client = new LogTransferService.Client(protocol); client.Log(logPackage); long data_size = trans.DataSize; trans.Close(); return(data_size); }
static void Main(string[] args) { Uri uri = new Uri("http://localhost:8911/"); THttpClient httpClient = new THttpClient(uri); TProtocol protocol = new TBinaryProtocol(httpClient); HelloService.Client client = new HelloService.Client(protocol); httpClient.Open(); Console.WriteLine("Client calls ....."); Console.WriteLine(client.hello("jian wang")); Console.WriteLine(client.add(1, 2)); httpClient.Close(); Console.ReadKey(); }
protected void Dispose(bool disposing) { if (!disposed) { disposed = true; if (disposing) { //dispose managed state httpClient.Close(); } else { System.Diagnostics.Debug.Assert(false); // you MUST dispose this object explicitely or be doomed. } httpClient = null; protocol = null; GC.SuppressFinalize(this); } }
static void Main(string[] args) { try { TTransport transport = new THttpClient(new Uri("http://*****:*****@justiceleague.com" }, new Contact { FirstName = "Clark", LastName = "Kent", Email = "*****@*****.**" } }); foreach (var e in contacts) { Console.WriteLine(e); } } finally { transport.Close(); } } catch (TApplicationException exception) { Console.WriteLine(exception.StackTrace); } }