Package org.atmosphere.gwt.client

Examples of org.atmosphere.gwt.client.AtmosphereClientException


      if (!connected) {
        if (expectingDisconnection) {
          listener.onDisconnected();
        }
        else {
          listener.onError(new AtmosphereClientException("Unexpected disconnection"), false);
        }
      }
    }
  }
View Full Code Here


    }
  }

  private void parse(String message, List<Serializable> messages) {
    if (expectingDisconnection) {
      listener.onError(new AtmosphereClientException("Expecting disconnection but received message: " + message), true);
    }
    else if (message.isEmpty()) {
      listener.onError(new AtmosphereClientException("Invalid empty message received"), true);
    }
    else {
      char c = message.charAt(0);
      switch (c) {
      case '!':
        String initParameters = message.substring(1);
        try {
                    String[] params = initParameters.split(":");
                    connectionId = Integer.parseInt(params[1]);
          listener.onConnected(Integer.parseInt(params[0]), connectionId);
        }
        catch (NumberFormatException e) {
          listener.onError(new AtmosphereClientException("Unexpected init parameters: " + initParameters), true);
        }
        break;
      case '?':
        // clean disconnection
        expectingDisconnection = true;
        break;
      case '#':
        listener.onHeartbeat();
        break;
      case '@':
        listener.onRefresh();
        break;
      case '*':
        // ignore padding
        break;
      case '|':
        messages.add(message.substring(1));
        break;
      case ']':
        messages.add(unescape(message.substring(1)));
        break;
      case '[':
      case 'R':
      case 'r':
      case 'f':
                try {
                    messages.add(parse(message));
                }
                catch (SerializationException e) {
                    listener.onError(e, true);
                }
        break;
      default:
        listener.onError(new AtmosphereClientException("Invalid message received: " + message), true);
      }
    }
  }
View Full Code Here

                String[] params = initParameters.split(":");
                connectionId = Integer.parseInt(params[1]);
        listener.onConnected(Integer.parseInt(params[0]), connectionId);
      }
      catch (NumberFormatException e) {
        listener.onError(new AtmosphereClientException("Unexpected init parameters: " + initParameters), true);
      }
    }
    else if (message.startsWith("e")) {
      disconnect();
      String status = message.substring(1);
      try {
        int statusCode;
        String statusMessage;
        int index = status.indexOf(' ');
        if (index == -1) {
          statusCode = Integer.parseInt(status);
          statusMessage = null;
        }
        else {
          statusCode = Integer.parseInt(status.substring(0, index));
          statusMessage = HTTPRequestCometTransport.unescape(status.substring(index + 1));
        }
        listener.onError(new StatusCodeException(statusCode, statusMessage), false);
      }
      catch (NumberFormatException e) {
        listener.onError(new AtmosphereClientException("Unexpected status code: " + status), false);
      }
    }
    else if (message.equals("d")) {
      connected = false;
      disconnect();
      listener.onDisconnected();
    }
    else if (message.equals("h")) {
      listener.onHeartbeat();
    }
    else {
      listener.onError(new AtmosphereClientException("Unexpected connection status: " + message), true);
    }
  }
View Full Code Here

                catch (SerializationException e) {
                    listener.onError(e, true);
                }
        break;
      default:
        listener.onError(new AtmosphereClientException("Invalid message received: " + message), true);
      }
    }
   
    listener.onMessage(messages);
  }
View Full Code Here

    body = null;
    if (expectingDisconnection) {
      listener.onDisconnected();
    }
    else {
      listener.onError(new AtmosphereClientException("Unexpected disconnection"), false);
    }
  }
View Full Code Here

    private boolean connected = false;

    @SuppressWarnings("unused")
    private final void logError(String message) {
        listener.onError(new AtmosphereClientException(message), connected);
    }
View Full Code Here

                String[] params = initParameters.split(":");
                connectionId = Integer.parseInt(params[1]);
        listener.onConnected(Integer.parseInt(params[0]), connectionId);
      }
      catch (NumberFormatException e) {
        listener.onError(new AtmosphereClientException("Unexpected init parameters: " + initParameters), true);
      }
    }
    else if (message.startsWith("e")) {
      disconnect();
      String status = message.substring(1);
      try {
        int statusCode;
        String statusMessage;
        int index = status.indexOf(' ');
        if (index == -1) {
          statusCode = Integer.parseInt(status);
          statusMessage = null;
        }
        else {
          statusCode = Integer.parseInt(status.substring(0, index));
          statusMessage = HTTPRequestCometTransport.unescape(status.substring(index + 1));
        }
        listener.onError(new StatusCodeException(statusCode, statusMessage), false);
      }
      catch (NumberFormatException e) {
        listener.onError(new AtmosphereClientException("Unexpected status code: " + status), false);
      }
    }
    else if (message.equals("d")) {
      disconnect();
    }
    else if (message.equals("h")) {
      listener.onHeartbeat();
    }
    else {
      listener.onError(new AtmosphereClientException("Unexpected connection status: " + message), true);
    }
    }
View Full Code Here

TOP

Related Classes of org.atmosphere.gwt.client.AtmosphereClientException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.