play.mvc
Class WebSocket<A>

java.lang.Object
  extended by play.mvc.WebSocket<A>

public abstract class WebSocket<A>
extends java.lang.Object

A WebSocket result.


Nested Class Summary
static class WebSocket.In<A>
          A WebSocket in.
static interface WebSocket.Out<A>
          A WebSocket out.
 
Constructor Summary
WebSocket()
           
 
Method Summary
 akka.actor.Props actorProps(akka.actor.ActorRef out)
          The props to create the actor to handle this WebSocket.
 boolean isActor()
          If this method returns true, then the WebSocket should be handled by an actor.
abstract  void onReady(WebSocket.In<A> in, WebSocket.Out<A> out)
          Called when the WebSocket is ready
static
<A> WebSocket<A>
reject(Result result)
          Rejects a WebSocket.
 Result rejectWith()
          If this method returns a result, the WebSocket will be rejected with that result.
static
<A> WebSocket<A>
whenReady(F.Callback2<WebSocket.In<A>,WebSocket.Out<A>> callback)
          Creates a WebSocket.
static
<A> WebSocket<A>
withActor(F.Function<akka.actor.ActorRef,akka.actor.Props> props)
          Handles a WebSocket with an actor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebSocket

public WebSocket()
Method Detail

onReady

public abstract void onReady(WebSocket.In<A> in,
                             WebSocket.Out<A> out)
Called when the WebSocket is ready

Parameters:
in - The Socket in.
out - The Socket out.

rejectWith

public Result rejectWith()
If this method returns a result, the WebSocket will be rejected with that result. This method will be invoked before onReady.

Returns:
The result to reject the WebSocket with, or null if the WebSocket shouldn't be rejected.

isActor

public boolean isActor()
If this method returns true, then the WebSocket should be handled by an actor. The actor will be obtained by passing an ActorRef representing to the actor method, which should return the props for creating the actor.


actorProps

public akka.actor.Props actorProps(akka.actor.ActorRef out)
The props to create the actor to handle this WebSocket.

Parameters:
out - The actor to send upstream messages to.
Returns:
The props of the actor to handle the WebSocket. If isActor returns true, must not return null.

whenReady

public static <A> WebSocket<A> whenReady(F.Callback2<WebSocket.In<A>,WebSocket.Out<A>> callback)
Creates a WebSocket. The abstract onReady method is implemented using the specified Callback2<In<A>, Out<A>>

Parameters:
callback - the callback used to implement onReady
Returns:
a new WebSocket
Throws:
java.lang.NullPointerException - if the specified callback is null

reject

public static <A> WebSocket<A> reject(Result result)
Rejects a WebSocket.

Parameters:
result - The result that will be returned.
Returns:
A rejected WebSocket.

withActor

public static <A> WebSocket<A> withActor(F.Function<akka.actor.ActorRef,akka.actor.Props> props)
Handles a WebSocket with an actor.

Parameters:
props - The function used to create the props for the actor. The passed in argument is the upstream actor.
Returns:
An actor WebSocket.