當前位置: 首頁>>代碼示例>>C#>>正文


C# TTransport.Open方法代碼示例

本文整理匯總了C#中Thrift.Transport.TTransport.Open方法的典型用法代碼示例。如果您正苦於以下問題:C# TTransport.Open方法的具體用法?C# TTransport.Open怎麽用?C# TTransport.Open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Thrift.Transport.TTransport的用法示例。


在下文中一共展示了TTransport.Open方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: initClient

 private void initClient()
 {
     transport = new TFramedTransport(new TSocket(SERVER_IP, SERVER_PORT, TIME_OUT));
     TProtocol protocol = new TBinaryProtocol(transport);
     client = new BigQueueService.Client(protocol);
     transport.Open();
 }
開發者ID:shshen,項目名稱:bigqueue,代碼行數:7,代碼來源:Program.cs

示例2: Setup

 public void Setup()
 {
     var socket = new TSocket(host, port);
     transport = new TFramedTransport(socket);
     var protocol = new TBinaryProtocol(transport);
     Client = new ZipkinCollector.Client(protocol);
     transport.Open();
 }
開發者ID:theburningmonk,項目名稱:Medidata.ZipkinTracerModule,代碼行數:8,代碼來源:ClientProvider.cs

示例3: MainController

        public MainController(MainWindow window)
        {
            this.window = window;
            this.nao = new NaoController(NAO_IP, this);

            this.thriftTransport = new TSocket(SERVER_IP, 9090);
            thriftTransport.Open();
            TProtocol protocol = new TBinaryProtocol(thriftTransport);
            this.thriftClient = new Rpc.Client(protocol);

            this.lib = new ObjectLibrary(this, this.thriftClient, MainController.OBJECT_LIB_PATH);
            this.updateThread = new Thread(this.lib.updatePointClouds);
            this.updateThread.Start();

            this.nav = new NavigationController(this, nao, lib);
            this.navThread = null;

            switchStates(State.waiting);
        }
開發者ID:omanamos,項目名稱:robotics,代碼行數:19,代碼來源:MainController.cs

示例4: Connect

        /// <summary>
        /// Establish a connection to the server (ARE)
        /// </summary>
        /// <param name="ipAddress">IP-Address of the ARE</param>
        /// <param name="port">Port to connect</param>
        /// <returns>A ASAPI-client object</returns>
        public AsapiServer.Client Connect(string ipAddress, int port, int timeOutParam)
        {
            int timeOut = 10000;

            if (timeOutParam == -1) {
                // read socket timeout from the ini-file
                try {
                    IniFile ini = null;
                    if (File.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini")) {
                        ini = new IniFile(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini");
                    } else if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini")) {
                        ini = new IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini");
                    }
                    if (ini != null) {
                        timeOut = int.Parse(ini.IniReadValue("ARE", "socket_timeout"));
                        if (timeOut < 100) {
                            timeOut = 10000;
                        }
                    }
                } catch (Exception) {
                }
            } else {
                timeOut = timeOutParam;
            }

            try {
                transport = new TSocket(ipAddress, port, timeOut); // set socket timeout to 10000ms
                protocol = new TBinaryProtocol(transport);
                client = new AsapiServer.Client(protocol);

                transport.Open();
                return client;

            } catch (Exception) { //catch (TApplicationException x) {
                //throw e;
                return null;
            }
        }
開發者ID:Walid-Shouman,項目名稱:AsTeRICS,代碼行數:44,代碼來源:asapiNetMain.cs

示例5: ClientTest

        public static void ClientTest(TTransport transport)
        {
            TBinaryProtocol binaryProtocol = new TBinaryProtocol(transport);

            ThriftTest.Client client = new ThriftTest.Client(binaryProtocol);
            try
            {
                if (!transport.IsOpen)
                {
                    transport.Open();
                }
            }
            catch (TTransportException ttx)
            {
                Console.WriteLine("Connect failed: " + ttx.Message);
                return;
            }

            long start = DateTime.Now.ToFileTime();

            Console.Write("testVoid()");
            client.testVoid();
            Console.WriteLine(" = void");

            Console.Write("testString(\"Test\")");
            string s = client.testString("Test");
            Console.WriteLine(" = \"" + s + "\"");

            Console.Write("testByte(1)");
            byte i8 = client.testByte((byte)1);
            Console.WriteLine(" = " + i8);

            Console.Write("testI32(-1)");
            int i32 = client.testI32(-1);
            Console.WriteLine(" = " + i32);

            Console.Write("testI64(-34359738368)");
            long i64 = client.testI64(-34359738368);
            Console.WriteLine(" = " + i64);

            Console.Write("testDouble(5.325098235)");
            double dub = client.testDouble(5.325098235);
            Console.WriteLine(" = " + dub);

            Console.Write("testStruct({\"Zero\", 1, -3, -5})");
            Xtruct o = new Xtruct();
            o.String_thing = "Zero";
            o.Byte_thing = (byte)1;
            o.I32_thing = -3;
            o.I64_thing = -5;
            Xtruct i = client.testStruct(o);
            Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");

            Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
            Xtruct2 o2 = new Xtruct2();
            o2.Byte_thing = (byte)1;
            o2.Struct_thing = o;
            o2.I32_thing = 5;
            Xtruct2 i2 = client.testNest(o2);
            i = i2.Struct_thing;
            Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}");

            Dictionary<int, int> mapout = new Dictionary<int, int>();
            for (int j = 0; j < 5; j++)
            {
                mapout[j] = j - 10;
            }
            Console.Write("testMap({");
            bool first = true;
            foreach (int key in mapout.Keys)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    Console.Write(", ");
                }
                Console.Write(key + " => " + mapout[key]);
            }
            Console.Write("})");

            Dictionary<int, int> mapin = client.testMap(mapout);

            Console.Write(" = {");
            first = true;
            foreach (int key in mapin.Keys)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    Console.Write(", ");
                }
                Console.Write(key + " => " + mapin[key]);
            }
            Console.WriteLine("}");
//.........這裏部分代碼省略.........
開發者ID:vicaya,項目名稱:thrift,代碼行數:101,代碼來源:TestClient.cs

示例6: ValidateInstance

 private void ValidateInstance(TTransport instance)
 {
     if (!instance.IsOpen)
     {
         instance.Open();
     }
 }
開發者ID:shentianyi,項目名稱:LEONIPack,代碼行數:7,代碼來源:ConnectionProvider.cs

示例7: connect

        public bool connect(String address, int port)
        {
            if(IsConnected)
            {
                //Don't bother trying to connect as we are already connected
                return true;
            }

            //Create a new thrift socket
            transport = new TSocket(address, port);

            try
            {
                //Attmept to open the transport
                transport.Open();
            }
            catch (Exception exp)
            {
                isConnected = false;

                return false;
            }

            //Create the protocol
            protocol = new TBinaryProtocol(transport);

            client = new Apache.Hadoop.Hbase.Thrift.Hbase.Client(protocol);

            //Flag the new connection status
            isConnected = true;

            return true;
        }
開發者ID:charliem,項目名稱:OCM,代碼行數:33,代碼來源:HbaseConnection.cs

示例8: ValidateOnBorrow

 /// <summary>
 /// 取出對象時校驗對象
 /// </summary>
 private void ValidateOnBorrow(TTransport instance)
 {
     if (!instance.IsOpen)
     {
         instance.Open();
     }
 }
開發者ID:complus206,項目名稱:arch,代碼行數:10,代碼來源:ThreadPool.cs

示例9: ClientTest

        public static void ClientTest(TTransport transport)
        {
            TProtocol proto;
            if (protocol == "compact")
                proto = new TCompactProtocol(transport);
            else if (protocol == "json")
                proto = new TJSONProtocol(transport);
            else
                proto = new TBinaryProtocol(transport);

            ThriftTest.Client client = new ThriftTest.Client(proto);
            try
            {
                if (!transport.IsOpen)
                {
                    transport.Open();
                }
            }
            catch (TTransportException ttx)
            {
                Console.WriteLine("Connect failed: " + ttx.Message);
                return;
            }

            long start = DateTime.Now.ToFileTime();

            Console.Write("testVoid()");
            client.testVoid();
            Console.WriteLine(" = void");

            Console.Write("testString(\"Test\")");
            string s = client.testString("Test");
            Console.WriteLine(" = \"" + s + "\"");

            Console.Write("testByte(1)");
            sbyte i8 = client.testByte((sbyte)1);
            Console.WriteLine(" = " + i8);

            Console.Write("testI32(-1)");
            int i32 = client.testI32(-1);
            Console.WriteLine(" = " + i32);

            Console.Write("testI64(-34359738368)");
            long i64 = client.testI64(-34359738368);
            Console.WriteLine(" = " + i64);

            Console.Write("testDouble(5.325098235)");
            double dub = client.testDouble(5.325098235);
            Console.WriteLine(" = " + dub);

            byte[] binOut = PrepareTestData(true);
            Console.Write("testBinary(" + BytesToHex(binOut) + ")");
            try
            {
                byte[] binIn = client.testBinary(binOut);
                Console.WriteLine(" = " + BytesToHex(binIn));
                if (binIn.Length != binOut.Length)
                    throw new Exception("testBinary: length mismatch");
                for (int ofs = 0; ofs < Math.Min(binIn.Length, binOut.Length); ++ofs)
                    if (binIn[ofs] != binOut[ofs])
                        throw new Exception("testBinary: content mismatch at offset " + ofs.ToString());
            }
            catch (Thrift.TApplicationException e)
            {
                Console.Write("testBinary(" + BytesToHex(binOut) + "): "+e.Message);
            }

            // binary equals? only with hashcode option enabled ...
            if( typeof(CrazyNesting).GetMethod("Equals").DeclaringType == typeof(CrazyNesting))
            {
                CrazyNesting one = new CrazyNesting();
                CrazyNesting two = new CrazyNesting();
                one.String_field = "crazy";
                two.String_field = "crazy";
                one.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
                two.Binary_field = new byte[10] { 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xFF };
                if (!one.Equals(two))
                    throw new Exception("CrazyNesting.Equals failed");
            }

            Console.Write("testStruct({\"Zero\", 1, -3, -5})");
            Xtruct o = new Xtruct();
            o.String_thing = "Zero";
            o.Byte_thing = (sbyte)1;
            o.I32_thing = -3;
            o.I64_thing = -5;
            Xtruct i = client.testStruct(o);
            Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}");

            Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})");
            Xtruct2 o2 = new Xtruct2();
            o2.Byte_thing = (sbyte)1;
            o2.Struct_thing = o;
            o2.I32_thing = 5;
            Xtruct2 i2 = client.testNest(o2);
            i = i2.Struct_thing;
            Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}");

            Dictionary<int, int> mapout = new Dictionary<int, int>();
            for (int j = 0; j < 5; j++)
//.........這裏部分代碼省略.........
開發者ID:luoaguo,項目名稱:thrift,代碼行數:101,代碼來源:TestClient.cs

示例10: Connect

        protected bool Connect(IPEndPoint endPoint)
        {
            _transport = new TSocket(endPoint.Address.ToString(), endPoint.Port);
            var proto = new TBinaryProtocol(_transport);
            _client = new Idaas.Database.Client(proto);
            Enumerations = new Enumerations(_client);
            Structures = new Structures(_client);
            Strings = new Strings(_client);
            Functions = new Functions(_client);
            Instructions = new Instructions(_client);
            Names = new Names(_client);
            TypeLibraries = new TypeLibraries(_client);

            _transport.Open();
            return true;
        }
開發者ID:nihilus,項目名稱:idaas,代碼行數:16,代碼來源:Database.cs


注:本文中的Thrift.Transport.TTransport.Open方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。