Search in sources :

Example 1 with Order

use of com.code.server.rpc.idl.Order in project summer by foxsugar.

the class RpcManager method testGame.

private static void testGame(int count) {
    for (int i = 0; i < count; i++) {
        try {
            synchronized (rpcLock) {
                TTransport adminTransport = TransportManager.getTransport("192.168.1.132", 9090);
                GameRPC.Client client = GameRpcClient.getAClient(adminTransport);
                // client.getUserInfo(1);
                Order order = new Order();
                order.setUserId(1);
                order.setNum(1);
                order.setType(1);
                client.charge(order);
                adminTransport.close();
            }
        } catch (Exception e) {
        }
    }
}
Also used : Order(com.code.server.rpc.idl.Order) TTransport(org.apache.thrift.transport.TTransport) GameRPC(com.code.server.rpc.idl.GameRPC) TTransportException(org.apache.thrift.transport.TTransportException) TException(org.apache.thrift.TException)

Example 2 with Order

use of com.code.server.rpc.idl.Order in project summer by foxsugar.

the class RpcManager method charge.

private static void charge(String ip, int id, int num) throws TException {
    TTransport adminTransport = new TFramedTransport(new TSocket(ip, 9090));
    adminTransport.open();
    // TTransport adminTransport = TransportManager.getTransport(ip, 9090);
    GameRPC.Client client = GameRpcClient.getAClient(adminTransport);
    // client.getUserInfo(1);
    Order order = new Order();
    order.setUserId(id);
    order.setNum(num);
    order.setType(1);
    int rtn = client.charge(order);
    adminTransport.close();
    // 充值成功
    if (rtn == 0) {
    // todo 插入一条充值记录
    }
}
Also used : Order(com.code.server.rpc.idl.Order) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransport(org.apache.thrift.transport.TTransport) GameRPC(com.code.server.rpc.idl.GameRPC) TSocket(org.apache.thrift.transport.TSocket)

Aggregations

GameRPC (com.code.server.rpc.idl.GameRPC)2 Order (com.code.server.rpc.idl.Order)2 TTransport (org.apache.thrift.transport.TTransport)2 TException (org.apache.thrift.TException)1 TFramedTransport (org.apache.thrift.transport.TFramedTransport)1 TSocket (org.apache.thrift.transport.TSocket)1 TTransportException (org.apache.thrift.transport.TTransportException)1