use of com.generallycloud.baseio.container.rtp.RTPException in project baseio by generallycloud.
the class RTPClient method setRTPHandle.
public void setRTPHandle(final RTPHandle handle) throws RTPException {
if (this.handle != null) {
return;
}
this.consumer.listen("invite", new OnMappedMessage() {
@Override
public void onReceive(MapMessage message) {
handle.onInvite(RTPClient.this, message);
}
});
this.consumer.listen("invite-reply", new OnMappedMessage() {
@Override
public void onReceive(MapMessage message) {
handle.onInviteReplyed(RTPClient.this, message);
}
});
this.consumer.listen("break", new OnMappedMessage() {
@Override
public void onReceive(MapMessage message) {
handle.onBreak(RTPClient.this, message);
}
});
this.handle = handle;
try {
this.consumer.receive(null);
} catch (MQException e) {
throw new RTPException(e);
}
}
use of com.generallycloud.baseio.container.rtp.RTPException in project baseio by generallycloud.
the class RTPClient method leaveRoom.
public boolean leaveRoom() throws RTPException {
try {
Authority authority = session.getAuthority();
if (authority == null) {
throw new RTPException("not login");
}
ProtobaseFuture future = session.request(RTPJoinRoomServlet.SERVICE_NAME, roomId);
this.handle.onBreak(this, new MapMessage("", authority.getUuid()));
return JmsUtil.isTrue(future);
} catch (IOException e) {
throw new RTPException(e.getMessage(), e);
}
}
use of com.generallycloud.baseio.container.rtp.RTPException in project baseio by generallycloud.
the class RTPClient method inviteCustomer.
public void inviteCustomer(String inviteUsername) throws RTPException {
if (roomId == null) {
throw new RTPException("none roomId,create room first");
}
Authority authority = session.getAuthority();
if (authority == null) {
throw new RTPException("not login");
}
MapMessage message = new MapMessage("msgId", inviteUsername);
message.put("eventName", "invite");
message.put("roomId", roomId);
message.put("inviteUsername", authority.getUsername());
try {
producer.offer(message);
} catch (MQException e) {
throw new RTPException(e);
}
this.inviteUsername = inviteUsername;
}
use of com.generallycloud.baseio.container.rtp.RTPException in project baseio by generallycloud.
the class RTPClient method createRoom.
public boolean createRoom(String inviteUsername) throws RTPException {
ProtobaseFuture future;
try {
future = session.request(RTPCreateRoomServlet.SERVICE_NAME, null);
} catch (IOException e) {
throw new RTPException(e.getMessage(), e);
}
String roomId = future.getReadText();
if ("-1".equals(roomId)) {
throw new RTPException("create room failed");
}
this.roomId = roomId;
this.inviteCustomer(inviteUsername);
return true;
}
use of com.generallycloud.baseio.container.rtp.RTPException in project baseio by generallycloud.
the class RTPClient method inviteReply.
public void inviteReply(String inviteUsername, int markinterval, long currentMark, int groupSize) throws RTPException {
MapMessage message = new MapMessage("msgId", inviteUsername);
message.put("eventName", "invite-reply");
message.put(MARK_INTERVAL, markinterval);
message.put(CURRENT_MARK, currentMark);
message.put(GROUP_SIZE, groupSize);
try {
producer.offer(message);
} catch (MQException e) {
throw new RTPException(e);
}
this.inviteUsername = inviteUsername;
}
Aggregations