com.twistedmatrix.spread.pb
Class Broker

java.lang.Object
  |
  +--com.twistedmatrix.spread.Banana
        |
        +--com.twistedmatrix.spread.pb.Broker

public class Broker
extends Banana

Network connection over which the PB protocol runs.


Inner Class Summary
static class Broker.Error
          An exception in the protocol.
 
Inner classes inherited from class com.twistedmatrix.spread.Banana
Banana.ProtocolException
 
Field Summary
protected static ByteString ANSWER
           
static ByteString CONNECTION_LOST
           
protected static ByteString DECREF
           
protected static ByteString DNU
           
protected static ByteString ERROR
           
protected static ByteString LOCAL
           
protected static ByteString MESSAGE
           
protected static java.lang.Integer protocolVersion
           
protected static ByteString REMOTE
           
protected static ByteString VERSION
           
 
Fields inherited from class com.twistedmatrix.spread.Banana
DIALECTS, disconnected, FLOAT, HIGH_BIT_SET, in, INT, LIST, LONGINT, LONGNEG, NEG, NONE, out, PB, STRING, VOCAB, vocabulary
 
Constructor Summary
Broker(JellyPolicy policy, StreamPair sp, boolean isClient)
          Create a new instance given a pair of streams.
Broker(StreamPair sp, boolean isClient)
          Create a new instance given a pair of streams.
 
Method Summary
 void close()
          Close the connection.
protected  void connectionLost()
           
protected  void expressionReceived(java.lang.Object exp)
           
 JellyPolicy getPolicy()
          Get the Broker's JellyPolicy.
 Referenceable localObjectForID(java.lang.Object objectID)
          Get local object that is being called by remote.
 void notifyOnDisconnect(Callback c)
          Register a callback for when the connection is lost.
 RemoteReference remoteForName(ByteString name)
          Get a reference to a remote object based on its name.
 java.lang.Integer remoteReference(Referenceable object)
          Register and get and ID for a local object.
protected  void sendAnswer(java.lang.Integer requestID, java.lang.Object netResult)
          Send an error response to a message.
protected  void sendDecRef(java.lang.Object objectID)
          Send a decref for an object.
protected  void sendError(java.lang.Integer requestID, Failure reason)
          Send an error response to a message.
protected  void sendMessage(ByteString perspective, java.lang.Object objectID, ByteString message, java.lang.Object[] args, PrimitiveMap kwargs, Callback callback)
          Send a message to a remote object.
protected  java.lang.Object serialize(java.lang.Object o)
          Serialize an object using Jelly.
 void setNameForLocal(ByteString name, Referenceable local)
          Set a string ID for an object.
 void start()
          Start running.
protected  java.lang.Object unserialize(java.lang.Object o)
          Unserialize an object using Jelly.
protected  java.lang.Object unserialize(java.lang.Object o, ByteString perspective)
          Unserialize an object using Jelly.
 
Methods inherited from class com.twistedmatrix.spread.Banana
handshake, read, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

protected static final ByteString VERSION

DNU

protected static final ByteString DNU

MESSAGE

protected static final ByteString MESSAGE

ANSWER

protected static final ByteString ANSWER

ERROR

protected static final ByteString ERROR

DECREF

protected static final ByteString DECREF

REMOTE

protected static final ByteString REMOTE

LOCAL

protected static final ByteString LOCAL

protocolVersion

protected static final java.lang.Integer protocolVersion

CONNECTION_LOST

public static final ByteString CONNECTION_LOST
Constructor Detail

Broker

public Broker(JellyPolicy policy,
              StreamPair sp,
              boolean isClient)
Create a new instance given a pair of streams.

Broker

public Broker(StreamPair sp,
              boolean isClient)
Create a new instance given a pair of streams.
Method Detail

start

public void start()
Start running.
Overrides:
start in class Banana

expressionReceived

protected void expressionReceived(java.lang.Object exp)

remoteReference

public java.lang.Integer remoteReference(Referenceable object)
Register and get and ID for a local object.

localObjectForID

public Referenceable localObjectForID(java.lang.Object objectID)
Get local object that is being called by remote.

setNameForLocal

public void setNameForLocal(ByteString name,
                            Referenceable local)
Set a string ID for an object.

notifyOnDisconnect

public void notifyOnDisconnect(Callback c)
Register a callback for when the connection is lost.

close

public void close()
Close the connection.
Overrides:
close in class Banana

getPolicy

public JellyPolicy getPolicy()
Get the Broker's JellyPolicy.

connectionLost

protected void connectionLost()

sendDecRef

protected void sendDecRef(java.lang.Object objectID)
Send a decref for an object.

sendError

protected void sendError(java.lang.Integer requestID,
                         Failure reason)
Send an error response to a message.

sendAnswer

protected void sendAnswer(java.lang.Integer requestID,
                          java.lang.Object netResult)
Send an error response to a message.

serialize

protected java.lang.Object serialize(java.lang.Object o)
Serialize an object using Jelly.

unserialize

protected java.lang.Object unserialize(java.lang.Object o,
                                       ByteString perspective)
Unserialize an object using Jelly.

unserialize

protected java.lang.Object unserialize(java.lang.Object o)
Unserialize an object using Jelly.

remoteForName

public RemoteReference remoteForName(ByteString name)
Get a reference to a remote object based on its name.

sendMessage

protected void sendMessage(ByteString perspective,
                           java.lang.Object objectID,
                           ByteString message,
                           java.lang.Object[] args,
                           PrimitiveMap kwargs,
                           Callback callback)
                    throws java.io.IOException
Send a message to a remote object.