Added support for server-initiated remote actors with clients getting a dummy handle to the remote actor

This commit is contained in:
Jonas Bonér 2010-02-16 15:39:09 +01:00
parent 8fb281f4b0
commit 41766bef22
6 changed files with 321 additions and 80 deletions

View file

@ -182,13 +182,19 @@ class RemoteServer extends Logging {
}
}
def shutdown = {
def shutdown = if (isRunning) {
RemoteServer.unregister(hostname, port)
openChannels.disconnect
openChannels.close.awaitUninterruptibly
bootstrap.releaseExternalResources
Cluster.deregisterLocalNode(hostname, port)
}
// TODO: register active object in RemoteServer as well
def register(actor: Actor) = if (isRunning) {
log.info("Registering server side remote actor [%s] with id [%s]", actor.getClass.getName, actor.id)
RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(actor.id, actor)
}
}
case class Codec(encoder : ChannelHandler, decoder : ChannelHandler)
@ -256,8 +262,7 @@ class RemoteServerHandler(
override def messageReceived(ctx: ChannelHandlerContext, event: MessageEvent) = {
val message = event.getMessage
if (message eq null) throw new IllegalStateException(
"Message in remote MessageEvent is null: " + event)
if (message eq null) throw new IllegalStateException("Message in remote MessageEvent is null: " + event)
if (message.isInstanceOf[RemoteRequest]) {
handleRemoteRequest(message.asInstanceOf[RemoteRequest], event.getChannel)
}