public static MapD.Client get_client(string host_or_uri, int port, bool http) { THttpClient httpTransport; TTransport transport; TBinaryProtocol protocol; TJSONProtocol jsonProtocol; MapD.Client client; try{ if (http) { Uri httpuri = new Uri(host_or_uri); httpTransport = new THttpClient(httpuri); jsonProtocol = new TJSONProtocol(httpTransport); client = new MapD.Client(jsonProtocol); httpTransport.Open(); return(client); } else { transport = new TSocket(host_or_uri, port); protocol = new TBinaryProtocol(transport); client = new MapD.Client(protocol); transport.Open(); return(client); } } catch (TException x) { Console.WriteLine(x.StackTrace); } return(null); }
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); }
private void btnDelete_Click(object sender, EventArgs e) { using (THttpClient transport = new THttpClient(new Uri("http://192.168.1.2:8080/api"))) { TProtocol protocol = new TBinaryProtocol(transport); BookApi.Client client = new BookApi.Client(protocol); transport.Open(); txtResultDelete.Text = client.deleteWord(txtDeleteWord.Text); } }
public static void Create(Action <Hades.Client> onCreate) { new Thread(() => { var uri = new Uri(NativeBuildConfig.HadesUrl); using (var transport = new THttpClient(uri)) using (var protocol = new TBinaryProtocol(transport)) using (var client = new Hades.Client(protocol)) { transport.Open(); onCreate(client); } }).Start(); }
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(); }
public static void Create(Action <Hades.Client> onCreate) { new Thread(() => { ServicePointManager.ServerCertificateValidationCallback += (p1, p2, p3, p4) => true; var uri = new Uri(NativeBuildConfig.HadesUrl); using (var transport = new THttpClient(uri)) using (var protocol = new TBinaryProtocol(transport)) using (var client = new Hades.Client(protocol)) { transport.Open(); onCreate(client); } }).Start(); }
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); } }