use of io.transport.sdk.exception.TransportException in project transporter by wang4ever.
the class Configuration method getHostAndPorts.
public List<HostAndPort> getHostAndPorts() {
if (this.hostAndPorts != null && !this.hostAndPorts.isEmpty())
return this.hostAndPorts;
try {
List<String> hostAndPortTxts = PropertyLoadConfig.getList(PropertyLoadConfig.CLUSTER_ADDR_PKEY);
for (String handp : hostAndPortTxts) {
String[] arr = handp.split("\\:");
this.hostAndPorts.add(new HostAndPort(arr[0], Integer.parseInt(arr[1])));
}
} catch (Exception e) {
throw new TransportException("Server address configuration in illegal format.", e);
}
return this.hostAndPorts;
}
use of io.transport.sdk.exception.TransportException in project transporter by wang4ever.
the class TransportChannel method close.
@Override
public void close() throws IOException {
try {
if (this.workerGroup != null)
this.workerGroup.shutdownGracefully();
if (this.channel != null)
this.channel.close();
} catch (Exception e) {
throw new TransportException(e);
} finally {
this.channel = null;
this.workerGroup = null;
this.bootstrap = null;
System.gc();
}
}
use of io.transport.sdk.exception.TransportException in project transporter by wang4ever.
the class TransportClient method groupcast.
/**
* 组播发送消息(指定的点对多one-to-many)
*
* @param toGroupId
* @param payload
* @return 通道对象(可用于控制同步发送方案: groupcast(..).sync())
* @throws TransportException
*/
public Future<Message> groupcast(String toGroupId, String payload) throws TransportException {
if (ByteBufs.isEmpty(toGroupId) || ByteBufs.isEmpty(payload))
throw new TransportException("'toGroupId/payload' is not allowed to be empty.");
String fromDeviceId = this.config.getDeviceId();
TransportMessage msg = new TransportMessage(MsgType.TRANSPORT_REQ, fromDeviceId, null, toGroupId, payload);
return this.execute(msg, true);
}
use of io.transport.sdk.exception.TransportException in project transporter by wang4ever.
the class TransportClient method registered.
/**
* 注册客户端连接认证(如:用于Web端ws连接认证)
*
* @param expiredSec
* 过期时间(s)
* @param deviceIdTokens
* 多个deviceId
* @return 通道对象(可用于控制同步发送方案: registered(..).sync())
* @throws TransportException
*/
public Future<Message> registered(int expiredSec, String... deviceIdTokens) throws TransportException {
if (!(deviceIdTokens != null && deviceIdTokens.length != 0))
throw new TransportException("The 'deviceIdTokens' is not allowed to be empty.");
if (expiredSec <= 0)
throw new TransportException("'expiredSec' is invalid.");
DeviceRegistMessage msg = new DeviceRegistMessage();
msg.setAppId(this.config.getAppId());
msg.setExpired(expiredSec);
msg.setClientDeviceIds(Arrays.asList(deviceIdTokens));
return this.execute(msg, true);
}
use of io.transport.sdk.exception.TransportException in project transporter by wang4ever.
the class TransportClients method groupcast.
/**
* 组播发送消息(指定的点对多one-to-many)
*
* @param toGroupId
* @param payload
* @return 通道对象(可用于控制同步发送方案: groupcast(..).sync())
* @throws TransportException
*/
public Future<Message> groupcast(String toGroupId, String payload) throws TransportException {
if (StringUtil.isNullOrEmpty(toGroupId) || StringUtil.isNullOrEmpty(payload))
throw new TransportException("'toGroupId/payload' is not allowed to be empty.");
String fromDeviceId = Constants.processSerial;
TransportMessage msg = new TransportMessage(MsgType.TRANSPORT_REQ, fromDeviceId, null, toGroupId, payload);
return this.execute(msg, true);
}
Aggregations