public void onError(Exception exception) { connectionEstablished = false; reConnectionRTMServer(); for (AVConnectionListener listener: connectionListeners.values()) { listener.onError(null, null); } }
public void onClose(int var1, String var2, boolean var3) { LOGGER.d("webSocket closed..."); connectionEstablished = false; for (AVConnectionListener listener: connectionListeners.values()) { listener.onWebSocketClose(); } }
/** * WebSocketClientMonitor interfaces */ public void onOpen() { LOGGER.d("webSocket established..."); connectionEstablished = true; retryConnectionCount = 0; for (AVConnectionListener listener: connectionListeners.values()) { listener.onWebSocketOpen(); } resetConnectingStatus(true); // auto send login packet. LoginPacket lp = new LoginPacket(); lp.setAppId(AVOSCloud.getApplicationId()); lp.setInstallationId(AVInstallation.getCurrentInstallation().getInstallationId()); this.sendPacket(lp); }
public void onMessage(ByteBuffer bytes) { WindTalker windTalker = WindTalker.getInstance(); Messages.GenericCommand command = windTalker.disassemblePacket(bytes); if (null == command) { return; } LOGGER.d("downlink: " + command.toString()); String peerId = command.getPeerId(); Integer requestKey = command.hasI() ? command.getI() : null; if (command.hasService() && command.getService() == LiveQueryLoginPacket.SERVICE_LIVE_QUERY) { peerId = LiveQueryOperationDelegate.LIVEQUERY_DEFAULT_ID; } else if (command.getCmd().getNumber() == Messages.CommandType.data_VALUE) { peerId = AVPushMessageListener.DEFAULT_ID; } else if (StringUtil.isEmpty(peerId)) { peerId = AVIMClient.getDefaultClient(); } AVConnectionListener listener = this.connectionListeners.get(peerId); if (null != listener) { listener.onMessageArriving(peerId, requestKey, command); } else { LOGGER.w("no peer subscribed message, ignore it. peerId=" + peerId + ", requestKey=" + requestKey); } }