// Path: src/main/java/com/goodow/realtime/channel/State.java
// @JsExport
// @JsType
// public enum State {
//   CONNECTING, OPEN, CLOSING, CLOSED;
//   public static final State values[] = values();
// }
// 
// Path: src/main/java/com/goodow/realtime/core/WebSocket.java
// public interface WebSocket {
//   /**
//    * Listens for events on a {@link WebSocket}.
//    */
//   interface WebSocketHandler {
// 
//     /**
//      * Called when the socket is closed. When the socket is closed, it cannot be reopened.
//      */
//     void onClose(JsonObject reason);
// 
//     /**
//      * Called when an error occurs on the socket.
//      */
//     void onError(String error);
// 
//     /**
//      * Called when the socket receives a message.
//      */
//     void onMessage(String message);
// 
//     /**
//      * Called when the socket is ready to receive messages.
//      */
//     void onOpen();
//   }
// 
//   /**
//    * Close the socket. The socket cannot be used again after calling close; the server must create a
//    * new socket.
//    */
//   void close();
// 
//   State getReadyState();
// 
//   void send(String data);
// 
//   void setListen(WebSocketHandler handler);
// }


import com.goodow.realtime.channel.State;
import com.goodow.realtime.core.WebSocket;
import com.goodow.realtime.json.Json;
import org.vertx.java.core.Handler;
import org.vertx.java.core.Vertx;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpClient;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
 * Copyright 2014 Goodow.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.goodow.realtime.channel.server.impl;




class VertxWebSocket implements WebSocket {
  private static final Logger log = Logger.getLogger(VertxWebSocket.class.getName());

  private org.vertx.java.core.http.WebSocket socket;
  private WebSocketHandler eventHandler;
  private State state;

  VertxWebSocket(Vertx vertx, String uri) {
// Path: src/main/java/com/goodow/realtime/channel/State.java
// @JsExport
// @JsType
// public enum State {
//   CONNECTING, OPEN, CLOSING, CLOSED;
//   public static final State values[] = values();
// }
// 
// Path: src/main/java/com/goodow/realtime/core/WebSocket.java
// public interface WebSocket {
//   /**
//    * Listens for events on a {@link WebSocket}.
//    */
//   interface WebSocketHandler {
// 
//     /**
//      * Called when the socket is closed. When the socket is closed, it cannot be reopened.
//      */
//     void onClose(JsonObject reason);
// 
//     /**
//      * Called when an error occurs on the socket.
//      */
//     void onError(String error);
// 
//     /**
//      * Called when the socket receives a message.
//      */
//     void onMessage(String message);
// 
//     /**
//      * Called when the socket is ready to receive messages.
//      */
//     void onOpen();
//   }
// 
//   /**
//    * Close the socket. The socket cannot be used again after calling close; the server must create a
//    * new socket.
//    */
//   void close();
// 
//   State getReadyState();
// 
//   void send(String data);
// 
//   void setListen(WebSocketHandler handler);
// }


// Path: src/main/java/com/goodow/realtime/channel/server/impl/VertxWebSocket.java
import com.goodow.realtime.channel.State;
import com.goodow.realtime.core.WebSocket;
import com.goodow.realtime.json.Json;
import org.vertx.java.core.Handler;
import org.vertx.java.core.Vertx;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.http.HttpClient;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * Copyright 2014 Goodow.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.goodow.realtime.channel.server.impl;




class VertxWebSocket implements WebSocket {
  private static final Logger log = Logger.getLogger(VertxWebSocket.class.getName());

  private org.vertx.java.core.http.WebSocket socket;
  private WebSocketHandler eventHandler;
  private State state;

  VertxWebSocket(Vertx vertx, String uri) {
    state = State.CONNECTING;