Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Apache thrift client:");

            try
            {
                TTransport            transport = new TSocket("localhost", 9090);
                TProtocol             protocol  = new TBinaryProtocol(transport);
                StorageService.Client client    = new StorageService.Client(protocol);

                transport.Open();
                try
                {
                    client.ping();
                    Console.WriteLine("ping()");
                    var list = client.storagePoints();
                    foreach (var p in list)
                    {
                        Console.WriteLine("Id: {0}, Name: {1}, Description: {2}", p.StorageId, p.Name, p.Description);
                    }
                    var result = client.read(1);
                    Console.WriteLine("read: " + result);

                    if (client.write(0, "uusi arvo"))
                    {
                        Console.WriteLine("write ok");
                    }
                    else
                    {
                        Console.WriteLine("write failed");
                    }
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Apache thrift client");

            try
            {
                TTransport            transport = new TSocket("localhost", 9090);
                TProtocol             protocol  = new TBinaryProtocol(transport);
                StorageService.Client client    = new StorageService.Client(protocol);

                transport.Open();
                try
                {
                    client.ping();
                    Console.WriteLine("ping()");

                    var list = client.storagePoints();
                    foreach (var item in list)
                    {
                        string description = "";
                        if (!string.IsNullOrEmpty(item.Description))
                        {
                            description = item.Description;
                        }
                        Console.WriteLine(string.Format("ID: {0} name:{1} description:{2}",
                                                        item.StorageId, item.Name, description));
                    }
                    var  result = client.read(0);
                    bool r      = client.write(0, "new value");
                    result = client.read(0);
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }
        }