// Path: gwt-io/src/main/java/com/threerings/nexus/client/GWTClient.java
// public class GWTClient extends NexusClient
// {
//     /** The default (root-relative) path at which we will make our WebSocket connections. */
//     public static final String DEFAULT_WS_PATH = "/nexusws";
// 
//     /**
//      * Creates a Nexus client which will use WebSockets to connect to hosts.
//      * @param port the port on which to make WebSocket connections.
//      * @param path the path to the GWTIO WebSockets servlet. Must start with '/'.
//      * @param szer the serializer that knows about all types that will cross the wire.
//      */
//     public static NexusClient create (int port, String path, Serializer szer) {
//         if (!path.startsWith("/")) throw new IllegalArgumentException("Path must start with '/'.");
//         Log.log = GWT_LOGGER; // configure the logger to use GWT
//         return new GWTClient(port, path, szer);
//     }
// 
//     /**
//      * Creates a Nexus client which will use WebSockets to connect to hosts. Uses the default
//      * servlet path (i.e. {@link #DEFAULT_WS_PATH}).
//      * @param port the port on which to make WebSocket connections.
//      * @param szer the serializer that knows about all types that will cross the wire.
//      */
//     public static NexusClient create (int port, Serializer szer) {
//         return create(port, DEFAULT_WS_PATH, szer);
//     }
// 
//     protected GWTClient (int port, String path, Serializer szer) {
//         _port = port;
//         _path = path;
//         _szer = szer;
//     }
// 
//     @Override protected int port () {
//         return _port;
//     }
// 
//     @Override protected void connect (String host, RPromise<Connection> callback) {
//         new GWTConnection(host, _port, _path, _szer, callback);
//     }
// 
//     protected final int _port;
//     protected final String _path;
//     protected final Serializer _szer;
// 
//     protected static final Log.Logger GWT_LOGGER = new Log.Logger() {
//         @Override public void temp (String message, Object... args) {
//             format(null, message, args);
//         }
//         @Override public void info (String message, Object... args) {
//             if (!_warnOnly) {
//                 format(null, message, args);
//             }
//         }
//         @Override public void warning (String message, Object... args) {
//             format(null, message, args);
//         }
//         @Override public void log (Object level, String message, Throwable cause) {
//             if (GWT.isScript()) {
//                 sendToBrowserConsole(message, cause);
//             } else {
//                 GWT.log(message, cause);
//             }
//         }
//         @Override public void setWarnOnly (boolean warnOnly) {
//             _warnOnly = warnOnly;
//         }
//         protected boolean _warnOnly;
//     };
// 
//     protected static native void sendToBrowserConsole(String msg, Throwable e) /*-{
//         if ($wnd.console && $wnd.console.info) {
//             if (e != null) {
//                 $wnd.console.info(msg, e);
//             } else {
//                 $wnd.console.info(msg);
//             }
//         }
//     }-*/;
// }
// 
// Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java
// public class NexusException extends RuntimeException
//     implements Streamable
// {
//     /**
//      * Throws a NexusException with the supplied error message if {@code condition} is not true.
//      */
//     public static void require (boolean condition, String errmsg, Object... args) {
//         if (!condition) throw new NexusException(Log.format(errmsg, args));
//     }
// 
//     public NexusException (String message) {
//         super(message);
//     }
// 
//     public NexusException (String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public NexusException (Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: core/src/main/java/com/threerings/nexus/io/Serializer.java
// public interface Serializer
// {
//     /** Returns the class assigned the supplied code.
//      * @throws NexusException if no class is registered for the supplied code. */
//     Class<?> getClass (short code);
// 
//     /** Returns the streamer for the class assigned the supplied code.
//      * @throws NexusException if no streamer is registered for the supplied code.  */
//     Streamer<?> getStreamer (short code);
// 
//     /** Returns the service factory for the class assigned the supplied code.
//      * @throws NexusException if no service is registered for the supplied code.  */
//     DService.Factory<?> getServiceFactory (short code);
// 
//     /** Returns the code assigned to the supplied class.
//      * @throws NexusException if the class in question is not registered. */
//     short getCode (Class<?> clazz);
// 
//     /** Returns the code assigned to the supplied service class.
//      * @throws NexusException if the class in question is not registered. */
//     short getServiceCode (Class<? extends NexusService> clazz);
// 
//     /** Writes the class code for the supplied value, and returns the streamer for same.
//      * @throws NexusException if the class for the value in question is not registered. */
//     <T> Streamer<T> writeStreamer (Streamable.Output out, T value);
// }


import java.io.File;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import com.threerings.nexus.client.GWTClient;
import com.threerings.nexus.distrib.NexusException;
import com.threerings.nexus.io.Serializer;
//
// Nexus GWTServer - server-side support for Nexus GWT/WebSockets services
// http://github.com/threerings/nexus/blob/master/LICENSE

package com.threerings.nexus.server;




/**
 * Handles starting a Jetty server and configuring it to listen for GWTIO WebSocket requests on a
 * specified port. For systems that don't otherwise make use of Jetty, this simplifies things.
 * Systems that do make use of Jetty can simply wire up the {@link GWTIOJettyServlet} themselves.
 */
public class GWTConnectionManager
{
    /**
     * Creates a Jetty server that listens on the specified hostname and port and binds the
     * WebSocket servlet to the {@link GWTClient#DEFAULT_WS_PATH}.
     */
// Path: gwt-io/src/main/java/com/threerings/nexus/client/GWTClient.java
// public class GWTClient extends NexusClient
// {
//     /** The default (root-relative) path at which we will make our WebSocket connections. */
//     public static final String DEFAULT_WS_PATH = "/nexusws";
// 
//     /**
//      * Creates a Nexus client which will use WebSockets to connect to hosts.
//      * @param port the port on which to make WebSocket connections.
//      * @param path the path to the GWTIO WebSockets servlet. Must start with '/'.
//      * @param szer the serializer that knows about all types that will cross the wire.
//      */
//     public static NexusClient create (int port, String path, Serializer szer) {
//         if (!path.startsWith("/")) throw new IllegalArgumentException("Path must start with '/'.");
//         Log.log = GWT_LOGGER; // configure the logger to use GWT
//         return new GWTClient(port, path, szer);
//     }
// 
//     /**
//      * Creates a Nexus client which will use WebSockets to connect to hosts. Uses the default
//      * servlet path (i.e. {@link #DEFAULT_WS_PATH}).
//      * @param port the port on which to make WebSocket connections.
//      * @param szer the serializer that knows about all types that will cross the wire.
//      */
//     public static NexusClient create (int port, Serializer szer) {
//         return create(port, DEFAULT_WS_PATH, szer);
//     }
// 
//     protected GWTClient (int port, String path, Serializer szer) {
//         _port = port;
//         _path = path;
//         _szer = szer;
//     }
// 
//     @Override protected int port () {
//         return _port;
//     }
// 
//     @Override protected void connect (String host, RPromise<Connection> callback) {
//         new GWTConnection(host, _port, _path, _szer, callback);
//     }
// 
//     protected final int _port;
//     protected final String _path;
//     protected final Serializer _szer;
// 
//     protected static final Log.Logger GWT_LOGGER = new Log.Logger() {
//         @Override public void temp (String message, Object... args) {
//             format(null, message, args);
//         }
//         @Override public void info (String message, Object... args) {
//             if (!_warnOnly) {
//                 format(null, message, args);
//             }
//         }
//         @Override public void warning (String message, Object... args) {
//             format(null, message, args);
//         }
//         @Override public void log (Object level, String message, Throwable cause) {
//             if (GWT.isScript()) {
//                 sendToBrowserConsole(message, cause);
//             } else {
//                 GWT.log(message, cause);
//             }
//         }
//         @Override public void setWarnOnly (boolean warnOnly) {
//             _warnOnly = warnOnly;
//         }
//         protected boolean _warnOnly;
//     };
// 
//     protected static native void sendToBrowserConsole(String msg, Throwable e) /*-{
//         if ($wnd.console && $wnd.console.info) {
//             if (e != null) {
//                 $wnd.console.info(msg, e);
//             } else {
//                 $wnd.console.info(msg);
//             }
//         }
//     }-*/;
// }
// 
// Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java
// public class NexusException extends RuntimeException
//     implements Streamable
// {
//     /**
//      * Throws a NexusException with the supplied error message if {@code condition} is not true.
//      */
//     public static void require (boolean condition, String errmsg, Object... args) {
//         if (!condition) throw new NexusException(Log.format(errmsg, args));
//     }
// 
//     public NexusException (String message) {
//         super(message);
//     }
// 
//     public NexusException (String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public NexusException (Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: core/src/main/java/com/threerings/nexus/io/Serializer.java
// public interface Serializer
// {
//     /** Returns the class assigned the supplied code.
//      * @throws NexusException if no class is registered for the supplied code. */
//     Class<?> getClass (short code);
// 
//     /** Returns the streamer for the class assigned the supplied code.
//      * @throws NexusException if no streamer is registered for the supplied code.  */
//     Streamer<?> getStreamer (short code);
// 
//     /** Returns the service factory for the class assigned the supplied code.
//      * @throws NexusException if no service is registered for the supplied code.  */
//     DService.Factory<?> getServiceFactory (short code);
// 
//     /** Returns the code assigned to the supplied class.
//      * @throws NexusException if the class in question is not registered. */
//     short getCode (Class<?> clazz);
// 
//     /** Returns the code assigned to the supplied service class.
//      * @throws NexusException if the class in question is not registered. */
//     short getServiceCode (Class<? extends NexusService> clazz);
// 
//     /** Writes the class code for the supplied value, and returns the streamer for same.
//      * @throws NexusException if the class for the value in question is not registered. */
//     <T> Streamer<T> writeStreamer (Streamable.Output out, T value);
// }


// Path: gwt-server/src/main/java/com/threerings/nexus/server/GWTConnectionManager.java
import java.io.File;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import com.threerings.nexus.client.GWTClient;
import com.threerings.nexus.distrib.NexusException;
import com.threerings.nexus.io.Serializer;

//
// Nexus GWTServer - server-side support for Nexus GWT/WebSockets services
// http://github.com/threerings/nexus/blob/master/LICENSE

package com.threerings.nexus.server;




/**
 * Handles starting a Jetty server and configuring it to listen for GWTIO WebSocket requests on a
 * specified port. For systems that don't otherwise make use of Jetty, this simplifies things.
 * Systems that do make use of Jetty can simply wire up the {@link GWTIOJettyServlet} themselves.
 */
public class GWTConnectionManager
{
    /**
     * Creates a Jetty server that listens on the specified hostname and port and binds the
     * WebSocket servlet to the {@link GWTClient#DEFAULT_WS_PATH}.
     */
    public GWTConnectionManager (SessionManager smgr, Serializer szer, String hostname, int port) {