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; package com.jme3.network.service;
import com.jme3.network.Client;
/** /**
* Convenient base class for ClientServices providing some default ClientService * Convenient base class for ClientServices providing some default ClientService
@ -48,4 +49,13 @@ public abstract class AbstractClientService extends AbstractService<ClientServic
protected AbstractClientService() { 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

@ -50,6 +50,15 @@ public abstract class AbstractHostedService extends AbstractService<HostedServic
protected AbstractHostedService() { 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 * Default implementation does nothing. Implementations can