Codota Logo
HostedServiceManager
Code IndexAdd Codota to your IDE (free)

How to use
HostedServiceManager
in
com.jme3.network.service

Best Java code snippets using com.jme3.network.service.HostedServiceManager (Showing top 20 results out of 315)

origin: jMonkeyEngine/jmonkeyengine

protected void addStandardServices() {
  log.fine("Adding standard services...");
  services.addService(new ServerSerializerRegistrationsService());
}
origin: jMonkeyEngine/jmonkeyengine

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 );
  }
}   
origin: jMonkeyEngine/jmonkeyengine

@Override
public void connectionAdded(Server server, HostedConnection hc) {
  addConnection(hc);
}
origin: jMonkeyEngine/jmonkeyengine

@Override
public void close() 
{
  if( !isRunning )
    throw new IllegalStateException( "Server is not started." );
  // First stop the services since we are about to
  // kill the connections they are using
  services.stop();
  try {
    // Kill the adpaters, they will kill the kernels
    for( KernelAdapter ka : channels ) {
      ka.close();
    }
    
    isRunning = false;
    
    // Now terminate all of the services
    services.terminate();             
  } catch( InterruptedException e ) {
    throw new RuntimeException( "Interrupted while closing", e );
  }                               
}
origin: tonihele/OpenKeeper

public void start() throws IOException {
  if (server == null) {
    server = Network.createServer(NetworkConstants.GAME_NAME, NetworkConstants.PROTOCOL_VERSION, port, port);
  }
  server.addChannel(port + 1); // Lobby
  server.addChannel(port + 2); // Chat
  initialize();
  server.addConnectionListener(new ServerConnectionListener(this));
  // Adding a delay for the connectionAdded right after the serializer registration
  // service gets to run let's the client get a small break in the buffer that should
  // generally prevent the RpcCall messages from coming too quickly and getting processed
  // before the SerializerRegistrationMessage has had a chance to process.
  // This "feature" happens with Linux almost all the time
  server.getServices().addService(new DelayService());
  server.getServices().addServices(new RpcHostedService(),
      new RmiHostedService(),
      new AccountHostedService(name),
      new LobbyHostedService(),
      new ChatHostedService()
  );
  // Add the SimEtheral host that will serve object sync updates to
  // the clients.
  EtherealHost ethereal = new EtherealHost(NetworkConstants.OBJECT_PROTOCOL,
      NetworkConstants.ZONE_GRID,
      NetworkConstants.ZONE_RADIUS);
  server.getServices().addService(ethereal);
  server.start();
  start = System.nanoTime();
}
origin: jMonkeyEngine/jmonkeyengine

/**
 *  Returns the server for this hosted service or null if
 *  the service is not yet attached.
 */   
protected Server getServer() {
  HostedServiceManager hsm = getServiceManager();
  return hsm == null ? null : hsm.getServer();
}
origin: jMonkeyEngine/jmonkeyengine

/**
 *  Called internally when a new connection has been added so that the
 *  services can be notified.
 */
protected void addConnection( HostedConnection hc ) {
  for( Service s : getServices() ) {
    ((HostedService)s).connectionAdded(server, hc);
  }
}
origin: jMonkeyEngine/jmonkeyengine

  @Override
  public void connectionRemoved(Server server, HostedConnection hc) {
    removeConnection(hc);
  }
}
origin: jMonkeyEngine/jmonkeyengine

@Override
public void start()
{
  if( isRunning )
    throw new IllegalStateException( "Server is already started." );
    
  // Initialize the kernels
  for( KernelAdapter ka : channels ) {
    ka.initialize();
  }
  // Start em up
  for( KernelAdapter ka : channels ) {
    ka.start();
  }
  
  isRunning = true;
  
  // Start the services
  services.start();             
}
origin: org.jmonkeyengine/jme3-networking

@Override
public void close() 
{
  if( !isRunning )
    throw new IllegalStateException( "Server is not started." );
  // First stop the services since we are about to
  // kill the connections they are using
  services.stop();
  try {
    // Kill the adpaters, they will kill the kernels
    for( KernelAdapter ka : channels ) {
      ka.close();
    }
    
    isRunning = false;
    
    // Now terminate all of the services
    services.terminate();             
  } catch( InterruptedException e ) {
    throw new RuntimeException( "Interrupted while closing", e );
  }                               
}
origin: jMonkeyEngine/jmonkeyengine

/**
 *  Used internally to remove the message delegator from the
 *  server.
 */
@Override
public void terminate(HostedServiceManager serviceManager) {
  Server server = serviceManager.getServer();
  server.removeMessageListener(delegator, delegator.getMessageTypes());
}
origin: jMonkeyEngine/jmonkeyengine

/**
 *  Called internally when a connection has been removed so that the
 *  services can be notified.
 */   
protected void removeConnection( HostedConnection hc ) {
  for( Service s : getServices() ) {
    ((HostedService)s).connectionRemoved(server, hc);
  }
}
origin: org.jmonkeyengine/jme3-networking

  @Override
  public void connectionRemoved(Server server, HostedConnection hc) {
    removeConnection(hc);
  }
}
origin: org.jmonkeyengine/jme3-networking

@Override
public void start()
{
  if( isRunning )
    throw new IllegalStateException( "Server is already started." );
    
  // Initialize the kernels
  for( KernelAdapter ka : channels ) {
    ka.initialize();
  }
  // Start em up
  for( KernelAdapter ka : channels ) {
    ka.start();
  }
  
  isRunning = true;
  
  // Start the services
  services.start();             
}
origin: jMonkeyEngine/jmonkeyengine

/**
 *  Used internally to setup the message delegator that will
 *  handle HostedConnection specific messages and forward them
 *  to that connection's RpcConnection.
 */
@Override
protected void onInitialize( HostedServiceManager serviceManager ) {
  Server server = serviceManager.getServer();
     // A general listener for forwarding the messages
  // to the client-specific handler
  this.delegator = new SessionDataDelegator(RpcConnection.class, 
                       ATTRIBUTE_NAME,
                       true);
  server.addMessageListener(delegator, delegator.getMessageTypes());
  if( log.isLoggable(Level.FINEST) ) {
    log.log(Level.FINEST, "Registered delegator for message types:{0}", Arrays.asList(delegator.getMessageTypes()));
  }
}
origin: org.jmonkeyengine/jme3-networking

protected void addStandardServices() {
  log.fine("Adding standard services...");
  services.addService(new ServerSerializerRegistrationsService());
}
origin: org.jmonkeyengine/jme3-networking

/**
 *  Called internally when a new connection has been added so that the
 *  services can be notified.
 */
protected void addConnection( HostedConnection hc ) {
  for( Service s : getServices() ) {
    ((HostedService)s).connectionAdded(server, hc);
  }
}
origin: org.jmonkeyengine/jme3-networking

@Override
public void connectionAdded(Server server, HostedConnection hc) {
  addConnection(hc);
}
origin: org.jmonkeyengine/jme3-networking

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 );
  }
}   
origin: org.jmonkeyengine/jme3-networking

/**
 *  Returns the server for this hosted service or null if
 *  the service is not yet attached.
 */   
protected Server getServer() {
  HostedServiceManager hsm = getServiceManager();
  return hsm == null ? null : hsm.getServer();
}
com.jme3.network.serviceHostedServiceManager

Javadoc

Manages HostedServices on behalf of a network Server object. All HostedServices are automatically informed about new and leaving connections.

Most used methods

  • addService
    Adds the specified HostedService and initializes it. If the service manager has already been started
  • <init>
    Creates a HostedServiceManager for the specified network Server.
  • addConnection
    Called internally when a new connection has been added so that the services can be notified.
  • getServer
    Returns the network Server associated with this HostedServiceManager.
  • getServices
  • removeConnection
    Called internally when a connection has been removed so that the services can be notified.
  • start
  • stop
  • terminate
  • addServices
    Adds all of the specified HostedServices and initializes them. If the service manager has already be
  • getService
  • getService

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • getSharedPreferences (Context)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now