Added getServer() and getClient() convenience methods.

This commit is contained in:
Paul Speed 2015-05-01 02:24:52 -04:00
parent e000d83ae7
commit a77ed52777
2 changed files with 19 additions and 0 deletions

View File

@ -32,6 +32,7 @@
package com.jme3.network.service;
import com.jme3.network.Client;
/**
* Convenient base class for ClientServices providing some default ClientService
@ -48,4 +49,13 @@ public abstract class AbstractClientService extends AbstractService<ClientServic
protected AbstractClientService() {
}
/**
* Returns the client for this client service or null if
* the service is not yet attached.
*/
protected Client getClient() {
ClientServiceManager csm = getServiceManager();
return csm == null ? null : csm.getClient();
}
}

View File

@ -51,6 +51,15 @@ public abstract class AbstractHostedService extends AbstractService<HostedServic
protected AbstractHostedService() {
}
/**
* 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();
}
/**
* Default implementation does nothing. Implementations can
* override this to peform custom new connection behavior.