public DefaultServer( String gameName, int version, Kernel reliable, Kernel fast ) { if( reliable == null ) throw new IllegalArgumentException( "Default server reqiures a reliable kernel instance." ); this.gameName = gameName; this.version = version; this.services = new HostedServiceManager(this); addStandardServices(); reliableAdapter = new KernelAdapter( this, reliable, dispatcher, true ); channels.add( reliableAdapter ); if( fast != null ) { fastAdapter = new KernelAdapter( this, fast, dispatcher, false ); channels.add( fastAdapter ); } }
@Override public int addChannel( int port ) { if( isRunning ) throw new IllegalStateException( "Channels cannot be added once server is started." ); // Note: it does bug me that channels aren't 100% universal and // setup externally but it requires a more invasive set of changes // for "connection types" and some kind of registry of kernel and // connector factories. This really would be the best approach and // would allow all kinds of channel customization maybe... but for // now, we hard-code the standard connections and treat the +2 extras // differently. // Check for consistency with the channels list if( channels.size() - CH_FIRST != alternatePorts.size() ) throw new IllegalStateException( "Channel and port lists do not match." ); try { int result = alternatePorts.size(); alternatePorts.add(port); Kernel kernel = kernelFactory.createKernel(result, port); channels.add( new KernelAdapter(this, kernel, dispatcher, true) ); return result; } catch( IOException e ) { throw new RuntimeException( "Error adding channel for port:" + port, e ); } }
public DefaultServer( String gameName, int version, Kernel reliable, Kernel fast ) { if( reliable == null ) throw new IllegalArgumentException( "Default server reqiures a reliable kernel instance." ); this.gameName = gameName; this.version = version; this.reliable = reliable; this.fast = fast; reliableAdapter = new KernelAdapter( this, reliable, dispatcher, true ); if( fast != null ) { fastAdapter = new KernelAdapter( this, fast, dispatcher, false ); } }
public DefaultServer( String gameName, int version, Kernel reliable, Kernel fast ) { if( reliable == null ) throw new IllegalArgumentException( "Default server reqiures a reliable kernel instance." ); this.gameName = gameName; this.version = version; this.services = new HostedServiceManager(this); addStandardServices(); reliableAdapter = new KernelAdapter( this, reliable, dispatcher, true ); channels.add( reliableAdapter ); if( fast != null ) { fastAdapter = new KernelAdapter( this, fast, dispatcher, false ); channels.add( fastAdapter ); } }
@Override public int addChannel( int port ) { if( isRunning ) throw new IllegalStateException( "Channels cannot be added once server is started." ); // Note: it does bug me that channels aren't 100% universal and // setup externally but it requires a more invasive set of changes // for "connection types" and some kind of registry of kernel and // connector factories. This really would be the best approach and // would allow all kinds of channel customization maybe... but for // now, we hard-code the standard connections and treat the +2 extras // differently. // Check for consistency with the channels list if( channels.size() - CH_FIRST != alternatePorts.size() ) throw new IllegalStateException( "Channel and port lists do not match." ); try { int result = alternatePorts.size(); alternatePorts.add(port); Kernel kernel = kernelFactory.createKernel(result, port); channels.add( new KernelAdapter(this, kernel, dispatcher, true) ); return result; } catch( IOException e ) { throw new RuntimeException( "Error adding channel for port:" + port, e ); } }