当前位置: 首页>>代码示例>>Java>>正文


Java JsonRpcHttpClient类代码示例

本文整理汇总了Java中com.googlecode.jsonrpc4j.JsonRpcHttpClient的典型用法代码示例。如果您正苦于以下问题:Java JsonRpcHttpClient类的具体用法?Java JsonRpcHttpClient怎么用?Java JsonRpcHttpClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonRpcHttpClient类属于com.googlecode.jsonrpc4j包,在下文中一共展示了JsonRpcHttpClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lobby);

    username = getIntent().getStringExtra("Username");
    teamName = getIntent().getStringExtra("TeamName");

    players = findViewById(R.id.players);

    //Add to SQL//Sets quiz bowl server and connects to it
    try {
        server = new URL("http:///127.0.01/QuizBowl.json");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    client = new JsonRpcHttpClient(server);
    quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);

    quizBowl.addUser(username, teamName, 0);
    startTimer();

}
 
开发者ID:DJRAppDev,项目名称:QuizBowlApp,代码行数:24,代码来源:LobbyActivity.java

示例2: BitcoinResource

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
private BitcoinResource() {
  this.config = new BitcoinConfiguration();
  concurrentRpcRequests = config.getMaxNodeConnections();

  try {
    // Set up our RPC authentication
    Authenticator.setDefault(new Authenticator() {
      @Override
      protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(config.getDaemonUser(),
            config.getDaemonPassword().toCharArray());
      }
    });

    this.client = new JsonRpcHttpClient(new URL(config.getDaemonConnectionString()));

  } catch (MalformedURLException e) {
    LOGGER.error(null, e);
  }
}
 
开发者ID:Braveno,项目名称:cosigner,代码行数:21,代码来源:BitcoinResource.java

示例3: createProxyFromKlass

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
private void createProxyFromKlass(String klassName, JsonRpcHttpClient client, Dictionary<String, Object> props, ImportDeclaration importDeclaration) throws BinderException {
    final Class<?> klass;
    // Use given klass
    try {
        klass = FuchsiaUtils.loadClass(context, klassName);
    } catch (ClassNotFoundException e) {
        throw new BinderException(
                "Cannot create a proxy for the ImportDeclaration : " + importDeclaration
                        + " unable to find a bundle which export the service class.", e
        );
    }

    // create the proxy !
    final Object proxy = ProxyUtil.createClientProxy(klass.getClassLoader(), klass, client);
    ServiceRegistration sReg = context.registerService(klassName, proxy, props);

    handleImportDeclaration(importDeclaration);

    String id = (String) importDeclaration.getMetadata().get(ID);
    // Add the registration to the registration list
    registrations.put(id, sReg);
}
 
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:23,代码来源:JSONRPCImporter.java

示例4: setupRemoteRpc

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
private void setupRemoteRpc() throws Exception {
    System.out.println("Creating RPC interface...");
    JsonRpcHttpClient httpClient = new JsonRpcHttpClient(new URL("http://localhost:8545"));
    final JsonRpc jsonRpc = ProxyUtil.createClientProxy(getClass().getClassLoader(), JsonRpc.class, httpClient);
    System.out.println("Pinging remote RPC...");
    String protocolVersion = jsonRpc.eth_protocolVersion();
    System.out.println("Remote OK. Version: " + protocolVersion);

    final String pTxFilterId = jsonRpc.eth_newPendingTransactionFilter();

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                while (Boolean.TRUE) {
                    Object[] changes = jsonRpc.eth_getFilterChanges(pTxFilterId);
                    if (changes.length > 0) {
                        for (Object change : changes) {
                            TransactionResultDTO tx = jsonRpc.eth_getTransactionByHash((String) change);
                            newRemotePendingTx(tx);
                        }
                    }
                    Thread.sleep(100);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:31,代码来源:PendingTxMonitor.java

示例5: onCreate

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gm_lobby);

    players = findViewById(R.id.players);
    startGame = findViewById(R.id.startGame);

    try {
        server = new URL("http://localhost:8080/quizbowl.json");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    client = new JsonRpcHttpClient(server);
    quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);

    String username = getIntent().getStringExtra("Username");
    quizBowl.addUser(username, "GameMaster", 1);
    startTimer();

    startGame.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            quizBowl.setLobbyState();
            Intent masterIntent = new Intent(GameMasterLobbyActivity.this, GameMasterActivity.class);
            startActivity(masterIntent);
        }
    });
}
 
开发者ID:DJRAppDev,项目名称:QuizBowlApp,代码行数:30,代码来源:GameMasterLobbyActivity.java

示例6: onCreate

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_team);

    createTeam = findViewById(R.id.createTeam);
    teamName = findViewById(R.id.teamName);

    //Final modifier might cause issues
    final String nameP = getIntent().getStringExtra("Username");

    //Sets quiz bowl server and connects to it
    try {
        server = new URL("http://localhost:8080/quizbowl.json");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    client = new JsonRpcHttpClient(server);
    quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);


    createTeam.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String nameT = teamName.getText().toString();
            //Pass team name to SQL
            quizBowl.addTeam(nameT);
            Intent intent = new Intent(CreateTeamActivity.this, LobbyActivity.class);
            intent.putExtra("Username", nameP);
            intent.putExtra("TeamName", nameT);
            startActivity(intent);
        }
    });
}
 
开发者ID:DJRAppDev,项目名称:QuizBowlApp,代码行数:35,代码来源:CreateTeamActivity.java

示例7: onCreate

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_end_game);

    scrollScores = findViewById(R.id.scores);
    exit = findViewById(R.id.exit);

    try {
        server = new URL("http://localhost:8080/quizbowl.json");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    client = new JsonRpcHttpClient(server);
    quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);

    ArrayList<Team> teamList = quizBowl.getTeams();
    for(int i = 0; i < teamList.size(); i++){
        addTeamPoints(teamList.get(i).getName() + " - " + teamList.get(i).getScore() + " points");
    }

    exit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
            System.exit(0);
        }
    });
}
 
开发者ID:DJRAppDev,项目名称:QuizBowlApp,代码行数:30,代码来源:EndGameActivity.java

示例8: EthRpcClient

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
/**
 * Constructor to specify hostname and port for ethereum client.
 *
 * @param hostname
 *            Hostname for ethereum client.
 * @param port
 *            Port for ethereum client.
 */
public EthRpcClient(String hostname, int port) {
    URL url;
    log.log(Level.INFO, "Geth address: " + hostname + ":" + port);
    try {
        url = new URL("http://" + hostname + ":" + port + "/");
        rpcClient = new JsonRpcHttpClient(url);
        rpc = ProxyUtil.createClientProxy(getClass().getClassLoader(), EthRpcInterface.class,
                rpcClient);

    } catch (MalformedURLException exception) {
        exception.printStackTrace();
    }
}
 
开发者ID:mudpedal,项目名称:cgk-tetherj,代码行数:22,代码来源:EthRpcClient.java

示例9: runJsonRpcHttpClient

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
public void runJsonRpcHttpClient() throws MalformedURLException {
  JsonRpcHttpClient jsonRpcHttpClient = new JsonRpcHttpClient(new URL(
      "http://127.0.0.1:" + JsonRpcServletEngine.PORT + "/"+ Config.appName.toLowerCase()));
  JsonRpcService service = ProxyUtil.createClientProxy(
      JsonRpcService.class.getClassLoader(), JsonRpcService.class,
      jsonRpcHttpClient);

  System.out.println(service.getBalance("1BckY64TE6VrjVcGMizYBE7gt22axnq6CM"));
}
 
开发者ID:ppkpub,项目名称:javatool,代码行数:10,代码来源:JsonRpcTest.java

示例10: EthRpcClient

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
/**
 * Constructor to specify hostname and port for ethereum client.
 *
 * @param hostname Hostname for ethereum client.
 * @param port     Port for ethereum client.
 */
public EthRpcClient(String hostname, int port) {
    URL url;
    logger.log(Level.INFO, "Geth address: " + hostname + ":" + port);
    try {
        url = new URL("http://" + hostname + ":" + port + "/");
        JsonRpcHttpClient rpcClient = new JsonRpcHttpClient(url);

        rpc = ProxyUtil.createClientProxy(getClass().getClassLoader(), EthRpcInterface.class,
                rpcClient);

    } catch (MalformedURLException exception) {
        exception.printStackTrace();
    }
}
 
开发者ID:cegeka,项目名称:tether,代码行数:21,代码来源:EthRpcClient.java

示例11: EthereumResource

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
private EthereumResource() {
  EthereumConfiguration config = new EthereumConfiguration();
  concurrentRpcRequests = config.getMaxNodeConnections();

  try {
    HashMap<String, String> headers = new HashMap<>();
    headers.put("Content-Type", "application/json");
    this.writeClient =
        new JsonRpcHttpClient(new URL(config.getDaemonConnectionString()), headers);
    this.readClient =
        new JsonRpcHttpClient(new URL(config.getDaemonReadConnectionString()), headers);
  } catch (MalformedURLException e) {
    LOGGER.error(null, e);
  }
}
 
开发者ID:Braveno,项目名称:cosigner,代码行数:16,代码来源:EthereumResource.java

示例12: main

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
public static void main(String[] args) throws Throwable {
    JsonRpcHttpClient jsonRpcHttpClient = new JsonRpcHttpClient(new URL("http://localhost:8099/com.doctor.jsonrpc.UserService"));
    String result = jsonRpcHttpClient.invoke("getName", new Object[] { "docotr who" }, String.class);
    System.out.println(result);

    // or user ProxyUtil
    UserService userService = ProxyUtil.createClientProxy(UserService.class.getClassLoader(), UserService.class, jsonRpcHttpClient);
    String name = userService.getName("doctor who !");
    System.out.println(name);
}
 
开发者ID:sdcuike,项目名称:book-reading,代码行数:11,代码来源:Practice01Client.java

示例13: initRpcClient

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
private void initRpcClient() {
	if (!endsWith(zbxUrl, "/")) {
		zbxUrl = zbxUrl + "/";
	}
	URL serverURL = null;
	try {
		serverURL = new URL(zbxUrl + API_RESOURCE);
	} catch (MalformedURLException e) {
		throw new RuntimeException(e);
	}
	rpcClient = new JsonRpcHttpClient(serverURL);
	rpcClient.setRequestListener(requestListener);
}
 
开发者ID:Ameausoone,项目名称:zabbix-java-client,代码行数:14,代码来源:ZabbixApiFactory.java

示例14: runJsonRpcHttpClient

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
public void runJsonRpcHttpClient() throws MalformedURLException {
	JsonRpcHttpClient jsonRpcHttpClient = new JsonRpcHttpClient(new URL(
			"http://127.0.0.1:" + JsonRpcServletEngine.PORT + "/"+ Config.appName.toLowerCase()));
	JsonRpcService service = ProxyUtil.createClientProxy(
			JsonRpcService.class.getClassLoader(), JsonRpcService.class,
			jsonRpcHttpClient);

	System.out.println(service.getBalance("1BckY64TE6VrjVcGMizYBE7gt22axnq6CM"));
	System.out.println(service.getSends("15QN22d2nzNM2FE9dyPrwAdLfxUkgavSUY"));
	System.out.println(service.getReceives("15QN22d2nzNM2FE9dyPrwAdLfxUkgavSUY"));
}
 
开发者ID:newbiecoin,项目名称:newbiecoinj,代码行数:12,代码来源:JsonRpcTest.java

示例15: testTimingOutRequests

import com.googlecode.jsonrpc4j.JsonRpcHttpClient; //导入依赖的package包/类
@Test
public void testTimingOutRequests() throws Exception {
	JsonRpcHttpClient client = getHttpClient(true, false);
	client.setReadTimeoutMillis(1);
	expectedEx.expectCause(isA(SocketTimeoutException.class));
	service = ProxyUtil.createClientProxy(this.getClass().getClassLoader(), FakeTimingOutService.class, client);
	service.doTimeout();
}
 
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:9,代码来源:TimeoutTest.java


注:本文中的com.googlecode.jsonrpc4j.JsonRpcHttpClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。