最近要做一个iOS端的VPN项目,在Android端已经有产品上线了——IP精灵。
客户要求使用Thrift的技术开发,然后只给了一些资料
- 一段Android连接VPN管理服务参考代码
- 一个gem-cocoa的源码文件
- 一个接口文档
参考代码如下
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。没办法了,关键的时候还是百度谷歌大法好。
网友评论