Repository: incubator-wave Updated Branches: refs/heads/master 2f2ec5ca8 -> 47cd2e99f
Removing old dependency with socketio-java https://reviews.apache.org/r/20610/ Project: http://git-wip-us.apache.org/repos/asf/incubator-wave/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-wave/commit/47cd2e99 Tree: http://git-wip-us.apache.org/repos/asf/incubator-wave/tree/47cd2e99 Diff: http://git-wip-us.apache.org/repos/asf/incubator-wave/diff/47cd2e99 Branch: refs/heads/master Commit: 47cd2e99fd65c7278622d659b410b4941a8df91a Parents: 2f2ec5c Author: vjrj <[email protected]> Authored: Thu May 1 13:01:33 2014 +0200 Committer: vjrj <[email protected]> Committed: Thu May 1 13:01:33 2014 +0200 ---------------------------------------------------------------------- .classpath | 3 - build.xml | 7 - .../waveprotocol/box/server/CoreSettings.java | 7 - .../server/rpc/AbstractWaveSocketIOServlet.java | 157 ------------------- .../box/server/rpc/ServerRpcProvider.java | 111 +------------ .../box/server/rpc/SocketIOServerChannel.java | 103 ------------ .../webclient/client/WaveWebSocketClient.java | 2 +- .../waveprotocol/box/server/rpc/RpcTest.java | 2 +- 8 files changed, 7 insertions(+), 385 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/.classpath ---------------------------------------------------------------------- diff --git a/.classpath b/.classpath index ea8d06a..679bce2 100644 --- a/.classpath +++ b/.classpath @@ -55,8 +55,6 @@ <classpathentry kind="lib" path="third_party/runtime/protobuf-format-java-1.1.jar"/> <classpathentry kind="lib" path="third_party/runtime/protobuf-java-2.5.0.jar"/> <classpathentry kind="lib" path="third_party/runtime/servlet-api-3.1.jar"/> - <classpathentry kind="lib" path="third_party/runtime/socketio-core-0.1-SNAPSHOT.jar"/> - <classpathentry kind="lib" path="third_party/runtime/socketio-jetty-0.1-SNAPSHOT.jar"/> <classpathentry kind="lib" path="third_party/runtime/websocket-client-9.1.1.v20140108.jar"/> <classpathentry kind="lib" path="third_party/runtime/websocket-common-9.1.1.v20140108.jar"/> <classpathentry kind="lib" path="third_party/runtime/websocket-server-9.1.1.v20140108.jar"/> @@ -78,7 +76,6 @@ <classpathentry kind="lib" path="third_party/test/mockito-all-1.9.5.jar"/> <classpathentry kind="lib" path="third_party/runtime/websocket-api-9.1.1.v20140108.jar"/> <classpathentry kind="lib" path="third_party/runtime/mongo-java-driver-2.11.2.jar"/> - <classpathentry kind="lib" path="third_party/codegen/socketio-gwt-0.1-SNAPSHOT.jar"/> <classpathentry kind="lib" path="third_party/codegen/gwt-dev-2.5.1.jar"/> <classpathentry kind="lib" path="third_party/codegen/gwt-user-2.5.1.jar"/> <classpathentry kind="lib" path="third_party/codegen/validation-api-1.1.0.Final-sources.jar"/> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/build.xml ---------------------------------------------------------------------- diff --git a/build.xml b/build.xml index 8f1fc77..83b2040 100644 --- a/build.xml +++ b/build.xml @@ -678,7 +678,6 @@ <include name="com/mongodb/**/*" /> <include name="org/slf4j/**/*" /> <include name="org/atmosphere/**/*" /> - <include name="com/glines/socketio/**/*" /> <include name="com/google/common/**/*" /> <include name="com/google/gson/**/*" /> <include name="com/google/gxp/**/*" /> @@ -951,8 +950,6 @@ <url url="http://central.maven.org/maven2/com/google/gwt/gwt-dev/2.5.1/gwt-dev-2.5.1.jar" /> <url url="http://central.maven.org/maven2/com/google/gwt/gwt-user/2.5.1/gwt-user-2.5.1.jar" /> <url url="http://central.maven.org/maven2/com/google/gwt/gwt-codeserver/2.5.1/gwt-codeserver-2.5.1.jar" /> - <url url="http://wave.alown.co.uk/third_party/socketio-gwt-0.1-SNAPSHOT.jar" /> - <url url="http://wave.alown.co.uk/third_party/socketio-gwt-0.1-SNAPSHOT-sources.jar" /> <url url="http://repo1.maven.org/maven2/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar" /> <url url="http://repo1.maven.org/maven2/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final-sources.jar" /> <url url="https://archive.apache.org/dist/velocity/engine/1.6.3/velocity-1.6.3.jar" /> @@ -1049,10 +1046,6 @@ <url url="https://oauth.googlecode.com/svn/code/maven/net/oauth/core/oauth-consumer/20100527/oauth-consumer-20100527.jar" /> <url url="http://central.maven.org/maven2/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar" /> <url url="https://protobuf-java-format.googlecode.com/files/protobuf-format-java-1.1.jar" /> - <url url="http://wave.alown.co.uk/third_party/socketio-core-0.1-SNAPSHOT.jar" /> - <url url="http://wave.alown.co.uk/third_party/socketio-core-0.1-SNAPSHOT-sources.jar" /> - <url url="http://wave.alown.co.uk/third_party/socketio-jetty-0.1-SNAPSHOT.jar" /> - <url url="http://wave.alown.co.uk/third_party/socketio-jetty-0.1-SNAPSHOT-sources.jar" /> <url url="http://wave.alown.co.uk/third_party/websocket.jar" /> <url url="http://wave.alown.co.uk/third_party/whack.jar" /> <url url="http://wave.alown.co.uk/third_party/xmpp.jar" /> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/src/org/waveprotocol/box/server/CoreSettings.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/CoreSettings.java b/src/org/waveprotocol/box/server/CoreSettings.java index 0a6f3fd..5b3fd0c 100644 --- a/src/org/waveprotocol/box/server/CoreSettings.java +++ b/src/org/waveprotocol/box/server/CoreSettings.java @@ -26,7 +26,6 @@ import java.util.List; /** * Core Wave in a Box settings */ -@SuppressWarnings("unused") // We inject them by the name of their flag public class CoreSettings { public static final String WAVE_SERVER_DOMAIN = "wave_server_domain"; public static final String HTTP_FRONTEND_PUBLIC_ADDRESS = "http_frontend_public_address"; @@ -48,7 +47,6 @@ public class CoreSettings { public static final String DELTA_STORE_DIRECTORY = "delta_store_directory"; public static final String SESSIONS_STORE_DIRECTORY = "sessions_store_directory"; public static final String SESSION_COOKIE_MAX_AGE = "session_cookie_max_age"; - public static final String FLASHSOCKET_POLICY_PORT = "flashsocket_policy_port"; public static final String WEBSOCKET_MAX_MESSAGE_SIZE = "websocket_max_message_size"; public static final String WEBSOCKET_MAX_IDLE_TIME = "websocket_max_idle_time"; public static final String GADGET_SERVER_HOSTNAME = "gadget_server_hostname"; @@ -159,11 +157,6 @@ public class CoreSettings { + "-1 means cookie lives in the browser current session only", defaultValue = "-1") private static int sessionCookieMaxAge; - @Setting(name = FLASHSOCKET_POLICY_PORT, - description = "Port on which to listen for Flashsocket policy requests.", - defaultValue = "843") - private static int flashsocketPolicyPort; - @Setting(name = WEBSOCKET_MAX_IDLE_TIME, description = "The time in ms that the websocket connection can be idle before closing", defaultValue = "0") private static int websocketMaxIdleTime; http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/src/org/waveprotocol/box/server/rpc/AbstractWaveSocketIOServlet.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/rpc/AbstractWaveSocketIOServlet.java b/src/org/waveprotocol/box/server/rpc/AbstractWaveSocketIOServlet.java deleted file mode 100644 index be90642..0000000 --- a/src/org/waveprotocol/box/server/rpc/AbstractWaveSocketIOServlet.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.waveprotocol.box.server.rpc; - - -import com.glines.socketio.server.AnnotationTransportHandlerProvider; -import com.glines.socketio.server.ServletBasedSocketIOConfig; -import com.glines.socketio.server.SocketIOConfig; -import com.glines.socketio.server.SocketIOInbound; -import com.glines.socketio.server.SocketIOServlet; -import com.glines.socketio.server.SocketIOSessionManager; -import com.glines.socketio.server.Transport; -import com.glines.socketio.server.TransportHandlerProvider; -import com.glines.socketio.server.TransportInitializationException; -import com.glines.socketio.server.TransportType; -import com.glines.socketio.util.IO; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public abstract class AbstractWaveSocketIOServlet extends HttpServlet { - - private static final Logger LOGGER = Logger.getLogger(SocketIOServlet.class.getName()); - private static final long serialVersionUID = 2L; - - private final SocketIOSessionManager sessionManager = new SocketIOSessionManager(); - private final TransportHandlerProvider transportHandlerProvider = new AnnotationTransportHandlerProvider(); - - private SocketIOConfig config; - private final Transport[] transports; - - public AbstractWaveSocketIOServlet(Transport...transports) { - this.transports = transports; - } - - @Override - public void init() throws ServletException { - config = new ServletBasedSocketIOConfig(getServletConfig(), "socketio"); - - // lazy load available transport handlers - transportHandlerProvider.init(); - if (LOGGER.isLoggable(Level.INFO)) - LOGGER.log(Level.INFO, "Transport handlers loaded: " + transportHandlerProvider.listAll()); - - // lazily load available transports - //TransportDiscovery transportDiscovery = new ClasspathTransportDiscovery(); - for (Transport transport : transports) { - if (transportHandlerProvider.isSupported(transport.getType())) { - transport.setTransportHandlerProvider(transportHandlerProvider); - config.addTransport(transport); - } else { - LOGGER.log(Level.WARNING, "Transport " + transport.getType() + " ignored since not supported by any TransportHandler"); - } - } - // initialize them - for (Transport t : config.getTransports()) { - try { - t.init(getServletConfig()); - } catch (TransportInitializationException e) { - config.removeTransport(t.getType()); - LOGGER.log(Level.WARNING, "Transport " + t.getType() + " disabled. Initialization failed: " + e.getMessage()); - } - } - if (LOGGER.isLoggable(Level.INFO)) - LOGGER.log(Level.INFO, "Transports loaded: " + config.getTransports()); - } - - @Override - public void destroy() { - for (Transport t : config.getTransports()) { - t.destroy(); - } - super.destroy(); - } - - @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - serve(req, resp); - } - - @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - serve(req, resp); - } - - /** - * Returns an instance of SocketIOInbound or null if the connection is to be denied. - * The value of cookies and protocols may be null. - */ - protected abstract SocketIOInbound doSocketIOConnect(HttpServletRequest request); - - private void serve(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - String path = request.getPathInfo(); - if (path == null || path.length() == 0 || "/".equals(path)) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing SocketIO transport"); - return; - } - if (path.startsWith("/")) path = path.substring(1); - String[] parts = path.split("/"); - - Transport transport = config.getTransport(TransportType.from(parts[0])); - if (transport == null) { - if ("GET".equals(request.getMethod()) && "socket.io.js".equals(parts[0])) { - response.setContentType("text/javascript"); - InputStream is = this.getClass().getClassLoader().getResourceAsStream("com/glines/socketio/socket.io.js"); - OutputStream os = response.getOutputStream(); - IO.copy(is, os); - return; - }else if ("GET".equals(request.getMethod()) && "WebSocketMain.swf".equals(parts[0])) { - response.setContentType("application/x-shockwave-flash"); - InputStream is = this.getClass().getClassLoader().getResourceAsStream("com/glines/socketio/WebSocketMain.swf"); - OutputStream os = response.getOutputStream(); - IO.copy(is, os); - return; - } else { - response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unknown SocketIO transport: " + parts[0]); - return; - } - } - - if (LOGGER.isLoggable(Level.FINE)) - LOGGER.log(Level.FINE, "Handling request from " + request.getRemoteHost() + ":" + request.getRemotePort() + " with transport: " + transport.getType()); - - transport.handle(request, response, new Transport.InboundFactory() { - @Override - public SocketIOInbound getInbound(HttpServletRequest request) { - return AbstractWaveSocketIOServlet.this.doSocketIOConnect(request); - } - }, sessionManager); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/src/org/waveprotocol/box/server/rpc/ServerRpcProvider.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/rpc/ServerRpcProvider.java b/src/org/waveprotocol/box/server/rpc/ServerRpcProvider.java index ca2f6b8..6332174 100755 --- a/src/org/waveprotocol/box/server/rpc/ServerRpcProvider.java +++ b/src/org/waveprotocol/box/server/rpc/ServerRpcProvider.java @@ -36,15 +36,6 @@ import com.google.protobuf.Message; import com.google.protobuf.RpcCallback; import com.google.protobuf.Service; -import com.glines.socketio.server.SocketIOInbound; -import com.glines.socketio.server.Transport; -import com.glines.socketio.server.transport.FlashSocketTransport; -import com.glines.socketio.server.transport.HTMLFileTransport; -import com.glines.socketio.server.transport.JSONPPollingTransport; -import com.glines.socketio.server.transport.XHRMultipartTransport; -import com.glines.socketio.server.transport.XHRPollingTransport; -import com.glines.socketio.server.transport.jetty.JettyWebSocketTransport; - import org.apache.commons.lang.StringUtils; import org.atmosphere.cache.UUIDBroadcasterCache; import org.atmosphere.config.service.AtmosphereHandlerService; @@ -99,14 +90,8 @@ import java.util.concurrent.Executors; import javax.annotation.Nullable; import javax.servlet.DispatcherType; -import javax.servlet.ServletConfig; import javax.servlet.ServletContextListener; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** @@ -119,13 +104,12 @@ public class ServerRpcProvider { private static final Log LOG = Log.get(ServerRpcProvider.class); /** - * The buffer size is passed to implementations of {@link AbstractWaveSocketIOServlet} as init + * The buffer size is passed to implementations of {@link WaveWebSocketServlet} as init * param. It defines the response buffer size. */ private static final int BUFFER_SIZE = 1024 * 1024; private final InetSocketAddress[] httpAddresses; - private final Integer flashsocketPolicyPort; private final ExecutorService threadPool; private final SessionManager sessionManager; private final org.eclipse.jetty.server.SessionManager jettySessionManager; @@ -177,26 +161,6 @@ public class ServerRpcProvider { } } - static class SocketIOConnection extends Connection { - private final SocketIOServerChannel socketChannel; - - SocketIOConnection(ParticipantId loggedInUser, ServerRpcProvider provider) { - super(loggedInUser, provider); - socketChannel = new SocketIOServerChannel(this); - LOG.info("New websocket connection set up for user " + loggedInUser); - expectMessages(socketChannel); - } - - @Override - protected void sendMessage(int sequenceNo, Message message) { - socketChannel.sendMessage(sequenceNo, message); - } - - public SocketIOServerChannel getWebSocketServerChannel() { - return socketChannel; - } - } - static class AtmosphereConnection extends Connection { private final AtmosphereChannel atmosphereChannel; @@ -340,12 +304,11 @@ public class ServerRpcProvider { * * Also accepts an ExecutorService for spawning managing threads. */ - public ServerRpcProvider(InetSocketAddress[] httpAddresses, Integer flashsocketPolicyPort, + public ServerRpcProvider(InetSocketAddress[] httpAddresses, String[] resourceBases, ExecutorService threadPool, SessionManager sessionManager, org.eclipse.jetty.server.SessionManager jettySessionManager, String sessionStoreDir, boolean sslEnabled, String sslKeystorePath, String sslKeystorePassword) { this.httpAddresses = httpAddresses; - this.flashsocketPolicyPort = flashsocketPolicyPort; this.resourceBases = resourceBases; this.threadPool = threadPool; this.sessionManager = sessionManager; @@ -359,11 +322,11 @@ public class ServerRpcProvider { /** * Constructs a new ServerRpcProvider with a default ExecutorService. */ - public ServerRpcProvider(InetSocketAddress[] httpAddresses, Integer flashsocketPolicyPort, + public ServerRpcProvider(InetSocketAddress[] httpAddresses, String[] resourceBases, SessionManager sessionManager, org.eclipse.jetty.server.SessionManager jettySessionManager, String sessionStoreDir, boolean sslEnabled, String sslKeystorePath, String sslKeystorePassword) { - this(httpAddresses, flashsocketPolicyPort, resourceBases, Executors.newCachedThreadPool(), + this(httpAddresses, resourceBases, Executors.newCachedThreadPool(), sessionManager, jettySessionManager, sessionStoreDir, sslEnabled, sslKeystorePath, sslKeystorePassword); } @@ -371,14 +334,13 @@ public class ServerRpcProvider { @Inject public ServerRpcProvider(@Named(CoreSettings.HTTP_FRONTEND_ADDRESSES) List<String> httpAddresses, @Named(CoreSettings.HTTP_WEBSOCKET_PUBLIC_ADDRESS) String websocketAddress, - @Named(CoreSettings.FLASHSOCKET_POLICY_PORT) Integer flashsocketPolicyPort, @Named(CoreSettings.RESOURCE_BASES) List<String> resourceBases, SessionManager sessionManager, org.eclipse.jetty.server.SessionManager jettySessionManager, @Named(CoreSettings.SESSIONS_STORE_DIRECTORY) String sessionStoreDir, @Named(CoreSettings.ENABLE_SSL) boolean sslEnabled, @Named(CoreSettings.SSL_KEYSTORE_PATH) String sslKeystorePath, @Named(CoreSettings.SSL_KEYSTORE_PASSWORD) String sslKeystorePassword) { - this(parseAddressList(httpAddresses, websocketAddress), flashsocketPolicyPort, resourceBases + this(parseAddressList(httpAddresses, websocketAddress), resourceBases .toArray(new String[0]), sessionManager, jettySessionManager, sessionStoreDir, sslEnabled, sslKeystorePath, sslKeystorePassword); } @@ -462,11 +424,6 @@ public class ServerRpcProvider { // TODO(zamfi): fix to let messages span frames. wsholder.setInitParameter("bufferSize", "" + BUFFER_SIZE); - // Set flash policy server parameters - String flashPolicyServerHost = "localhost"; - StringBuilder flashPolicyAllowedPorts = new StringBuilder(); - - // Atmosphere framework. Replacement of Socket.IO // See https://issues.apache.org/jira/browse/WAVE-405 ServletHolder atholder = addServlet("/atmosphere*", AtmosphereGuiceServlet.class); @@ -477,21 +434,6 @@ public class ServerRpcProvider { atholder.setAsyncSupported(true); atholder.setInitOrder(0); - /* - * Loop through addresses, collect list of ports, and determine if we are to use "localhost" - * of the AnyHost wildcard. - */ - for (InetSocketAddress addr: httpAddresses) { - if (flashPolicyAllowedPorts.length() > 0) { - flashPolicyAllowedPorts.append(","); - } - flashPolicyAllowedPorts.append(addr.getPort()); - if (!addr.getAddress().isLoopbackAddress()) { - // Until it's possible to pass a list of address, this is the only valid alternative. - flashPolicyServerHost = "0.0.0.0"; - } - } - // Serve the static content and GWT web client with the default servlet // (acts like a standard file-based web server). addServlet("/static/*", DefaultServlet.class); @@ -637,49 +579,6 @@ public class ServerRpcProvider { } } - @SuppressWarnings("serial") - @Singleton - public static class WaveSocketIOServlet extends HttpServlet { - - ServerRpcProvider provider; - - @Inject - public WaveSocketIOServlet(ServerRpcProvider provider) { - super(); - this.provider = provider; - } - - AbstractWaveSocketIOServlet socketIOServlet = new AbstractWaveSocketIOServlet( new Transport[] { - new XHRMultipartTransport(), new XHRPollingTransport(), new FlashSocketTransport(), - new JettyWebSocketTransport(), new JSONPPollingTransport(), new HTMLFileTransport()}) { - @Override - protected SocketIOInbound doSocketIOConnect(HttpServletRequest request) { - ParticipantId loggedInUser = provider.sessionManager.getLoggedInUser( - request.getSession(false)); - - SocketIOConnection connection = new SocketIOConnection(loggedInUser, provider); - return connection.getWebSocketServerChannel(); - } - }; - - @Override - public void init(ServletConfig config) throws ServletException { - socketIOServlet.init(config); - } - - @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - socketIOServlet.service(req, resp); - } - - @Override - public void service(ServletRequest req, ServletResponse res) - throws ServletException, IOException { - socketIOServlet.service(req, res); - } - } - /** * Manange atmosphere connections and dispatch messages to * wave channels. http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/src/org/waveprotocol/box/server/rpc/SocketIOServerChannel.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/rpc/SocketIOServerChannel.java b/src/org/waveprotocol/box/server/rpc/SocketIOServerChannel.java deleted file mode 100644 index 2f8ec13..0000000 --- a/src/org/waveprotocol/box/server/rpc/SocketIOServerChannel.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.waveprotocol.box.server.rpc; - -import com.glines.socketio.common.DisconnectReason; -import com.glines.socketio.common.SocketIOException; -import com.glines.socketio.server.SocketIOFrame; -import com.glines.socketio.server.SocketIOInbound; -import com.glines.socketio.server.SocketIOOutbound; - -import org.waveprotocol.wave.util.logging.Log; - -/** - * The server side of WebSocketChannel. - */ -public class SocketIOServerChannel extends WebSocketChannel implements SocketIOInbound { - private static final Log LOG = Log.get(SocketIOServerChannel.class); - - private SocketIOOutbound outbound; - - /** - * Creates a new WebSocketServerChannel using the callback for incoming messages. - * - * @param callback A ProtoCallback instance called with incoming messages. - */ - public SocketIOServerChannel(ProtoCallback callback) { - super(callback); - } - - /** - * Handles an incoming connection - * - * @param outbound The outbound direction of the new connection. - */ - @Override - public void onConnect(SocketIOOutbound outbound) { - this.outbound = outbound; - } - - /** - * Pass on an incoming String message. - * - * @param data The message data itself - */ - @Override - public void onMessage(int messageType, String data) { - if (SocketIOFrame.TEXT_MESSAGE_TYPE == messageType) { - handleMessageString(data); - } else { - LOG.warning("Recieved message of unexpected type: " + messageType); - } - } - - /** - * Handle a client disconnect. - */ - @Override - public void onDisconnect(DisconnectReason reason, String errorMessage) { - if (errorMessage == null) { - LOG.info("websocket disconnected["+reason+"]"); - } else { - LOG.info("websocket disconnected["+reason+"]: "+errorMessage); - } - synchronized (this) { - outbound = null; - } - } - - /** - * Send the given data String - * - * @param data - */ - @Override - protected void sendMessageString(String data) throws SocketIOException { - synchronized (this) { - if (outbound == null) { - // Just drop the message. It's rude to throw an exception since the - // caller had no way of knowing. - LOG.warning("Websocket is not connected"); - } else { - outbound.sendMessage(data); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/src/org/waveprotocol/box/webclient/client/WaveWebSocketClient.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/webclient/client/WaveWebSocketClient.java b/src/org/waveprotocol/box/webclient/client/WaveWebSocketClient.java index 0b68d71..92e3fd8 100644 --- a/src/org/waveprotocol/box/webclient/client/WaveWebSocketClient.java +++ b/src/org/waveprotocol/box/webclient/client/WaveWebSocketClient.java @@ -49,7 +49,7 @@ import java.util.Queue; /** - * Wrapper around SocketIO that handles the FedOne client-server protocol. + * Wrapper around WebSocket that handles the Wave client-server protocol. */ public class WaveWebSocketClient implements WaveSocket.WaveSocketCallback { private static final int MAX_INITIAL_FAILURES = 2; http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/47cd2e99/test/org/waveprotocol/box/server/rpc/RpcTest.java ---------------------------------------------------------------------- diff --git a/test/org/waveprotocol/box/server/rpc/RpcTest.java b/test/org/waveprotocol/box/server/rpc/RpcTest.java index d86ddf8..689d5c6 100644 --- a/test/org/waveprotocol/box/server/rpc/RpcTest.java +++ b/test/org/waveprotocol/box/server/rpc/RpcTest.java @@ -73,7 +73,7 @@ public class RpcTest extends TestCase { * This allows the test to run without clashing with any potentially in-use port. */ server = - new ServerRpcProvider(new InetSocketAddress[] {new InetSocketAddress("localhost", 0)}, 0, + new ServerRpcProvider(new InetSocketAddress[] {new InetSocketAddress("localhost", 0)}, new String[] {"./war"}, sessionManager, null, null, false, null, null); Injector injector = Guice.createInjector(new AbstractModule() { @Override
