Search in sources :

Example 1 with TransportClients

use of io.transport.sdk.TransportClients in project transporter by wang4ever.

the class MyTransportProgram method main.

public static void main(String[] args) throws Exception {
    // initialize.
    Configuration config = new Configuration(appId, appSecret, groupId, DeviceType.FRONTEND, MyReceiveTextHandler.class);
    // build join to server.
    TransportClients client = TransportClients.getInstance().build(config).join();
    // build.destroy(); // destroy instance.
    System.out.println("准备注册WS连接设备...");
    client.registered(24 * 60 * 60, "111111111122222222223333333333ab");
    Thread.sleep(2 * 1000L);
    String payload = "{\"testKey\":\"test1\", \"TestData\":\"发送给浏览器的测试JSON报文ABCDEFG123456\"}";
    long flag = 0l, count = 1;
    while (flag < count) {
        ++flag;
        // client.unicast(toDeviceId, payload);
        System.out.println("准备发送测试报文到浏览器 ,len=" + payload.getBytes(CharsetUtil.UTF_8).length);
        client.groupcast(toGroupId, payload);
        Thread.sleep(1 * 1000L);
    }
    Thread.sleep(15 * 60 * 1000L);
    System.exit(0);
}
Also used : Configuration(io.transport.sdk.Configuration) TransportClients(io.transport.sdk.TransportClients)

Aggregations

Configuration (io.transport.sdk.Configuration)1 TransportClients (io.transport.sdk.TransportClients)1