use of com.jme3.network.Message in project jmonkeyengine by jMonkeyEngine.
the class NioEndpoint method close.
public void close(boolean flushData) {
if (flushData) {
closing = true;
// Enqueue a close marker message to let the server
// know we should close
send(CLOSE_MARKER, false, true);
return;
}
try {
// Note: even though we may be disconnected from the socket.isConnected()
// standpoint, it's still safest to tell the kernel so that it can be sure
// to stop managing us gracefully.
kernel.closeEndpoint(this);
} catch (IOException e) {
throw new KernelException("Error closing endpoint for socket:" + socket, e);
}
}
use of com.jme3.network.Message in project jmonkeyengine by jMonkeyEngine.
the class RpcConnection method callAndWait.
/**
* Performs a remote procedure call with the specified arguments and waits
* for the response. Both the outbound message and inbound response will
* be sent on the specified channel.
*/
public Object callAndWait(byte channel, short objId, short procId, Object... args) {
RpcCallMessage msg = new RpcCallMessage(sequenceNumber.getAndIncrement(), channel, objId, procId, args);
// Need to register an object so we can wait for the response.
// ...before we send it. Just in case.
ResponseHolder holder = new ResponseHolder(msg);
responses.put(msg.getMessageId(), holder);
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST, "Sending:{0} on channel:{1}", new Object[] { msg, channel });
}
// so it doesn't do the check.
if (channel >= 0) {
connection.send(channel, msg);
} else {
connection.send(msg);
}
return holder.getResponse();
}
use of com.jme3.network.Message in project jmonkeyengine by jMonkeyEngine.
the class RpcHostedService method onInitialize.
/**
* 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()));
}
}
use of com.jme3.network.Message in project jmonkeyengine by jMonkeyEngine.
the class RpcHostedService method terminate.
/**
* 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());
}
use of com.jme3.network.Message in project jmonkeyengine by jMonkeyEngine.
the class RollingTheMonkey method reset.
private void reset() {
// Reset the pickups
for (Spatial pickUp : pickUps.getChildren()) {
GhostControl pickUpControl = pickUp.getControl(GhostControl.class);
if (pickUpControl != null) {
pickUpControl.setEnabled(true);
}
pickUp.setLocalScale(1.0f);
}
// Reset the player
player.setPhysicsLocation(PLAYER_START.clone());
player.setAngularVelocity(Vector3f.ZERO.clone());
player.setLinearVelocity(Vector3f.ZERO.clone());
// Reset the score
score = 0;
// Reset the message
messageText.setLocalScale(0.0f);
}
Aggregations