Пример #1
0
  @SuppressWarnings("unchecked")
  private void doneRefresh() {
    refreshState = null;
    CometClientTransportWrapper temp = primaryTransport;
    primaryTransport = refreshTransport;
    refreshTransport = temp;

    listener.onAfterRefresh();

    if (refreshQueue != null) {
      if (refreshQueue.size() > 0) {
        GWT.log("CometClient: pushing queued messages");
      }
      for (Object object : refreshQueue) {
        if (object == REFRESH) {
          doOnRefresh(primaryTransport);
        } else if (object == DISCONNECT) {
          doOnDisconnected(primaryTransport);
        } else {
          doOnMessage((List<?>) object, primaryTransport);
        }
      }
      refreshQueue.clear();
    }
  }
Пример #2
0
 private void doOnConnected(
     int heartbeat, int connectionID, CometClientTransportWrapper transport) {
   if (refreshState != null) {
     if (transport == refreshTransport) {
       if (refreshState == RefreshState.PRIMARY_DISCONNECTED) {
         doneRefresh();
       } else if (refreshState == RefreshState.CONNECTING) {
         primaryTransport.disconnect();
         doneRefresh();
       } else {
         throw new IllegalStateException("Unexpected refresh state");
       }
     } else {
       // refreshed connection after connection failed
       if (refreshState != RefreshState.CONNECTING) {
         throw new IllegalStateException("Unexpected refresh state");
       }
       refreshState = null;
       listener.onAfterRefresh();
     }
   } else {
     listener.onConnected(heartbeat, connectionID);
   }
 }