Thrift的二三事

Thrift的引入

2017-04-26  本文已影响36人  42e1dd428f25

最近要做一个iOS端的VPN项目,在Android端已经有产品上线了——IP精灵。

客户要求使用Thrift的技术开发,然后只给了一些资料

参考代码如下

public void run() {
    TTransport transport = null;
    try {
        // TSocket参数:服务端IP,服务端连接端口,连接超时时间(单位:毫秒),
        transport = new TFramedTransport(new TSocket(“127.0.0.1”, “8800”, 10000));
        TProtocol protocol = new TBinaryProtocol(transport);
        VpnManagerMainServer.Client client = new VpnManagerMainServer.Client(protocol);
        transport.open();
        
        //激活用户心跳接口
        byte activateResult = client.ActivateUserHeartbeat(_userVerify);
        
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putByte("ErrorNum", activateResult);
        msg.setData(b);
        
        //利用handler返回接收到的结果至主线程
        _handler.sendMessage(msg);
    } catch (Exception e) {
        e.printStackTrace();
        MyLogUtils.e("ActivateUserHeartbeatThread: " + e.getMessage());
        sendExceptionMessage();
    } finally {
        if (transport != null) {
            transport.close();
        }
    }
}

我就要根据这些资料进行我都不知道有多牛逼开发。

我的内心是痛苦的,一脸懵逼,之前从没接触过thrift。没办法了,关键的时候还是百度谷歌大法好。

上一篇 下一篇

猜你喜欢

热点阅读