Remote Procedures and Objects

MV3D follows the basic concepts from Twisted's Perspective Broker for RPCs and remotely available objects. This includes the following:

Viewable

A twisted.spread.pb.Viewable object is something that can be sent to the other side of a connection as a reference and then RPCs can be called against it. These calls are transformed into methods that start with view_ on the Viewable object. On the other side of the connection, making the calls is as easy as using the callRemote function on the twisted.spread.pb.RemoteReference object that the Viewable turns into. callRemote takes one required argument which is the name of the method to call (minus the "view_"). All other arguments to callRemote will be passed to the method when it is called.

Copyable

A mv3d.net.pb.Copyable object can be transmitted across the network. Attributes of the object will come with it as well. In order for a Copyable to be transmitted, readyClass must be called on the connection with a mv3d.util.classgen.ClassGenerator referring to the class of the Copyable. Any non-basic type that the Copyable wants to transmit with it must also be Copyable, Viewable, or Cacheable.

In order to specify what attributes are copied, you should use the allowedState list, which is a class level attribute. It contains a list of strings which refer to attribute names that should be transmitted with the parent object.

Cacheable

A mv3d.net.pb.Cacheable object can be transmitted across the network just like a Copyable, but in addition, the master object keeps track of all copies that have been transmitted. Calling updateAllClients(name, *args, **kwargs) on the master object will call "observe_name" with args and kwargs on all copies. There is also the concept of a special copy called the owner. This can be set with setOwner. It will reset to None if the owner goes away. When owner is set, updateOwningClient(name, *args, **kwargs) will call "observe_name" on the owning client while calling updateOtherClients(name, *args, **kwargs) will call it on all other clients. Cacheable objects should be used when it is important that the copies stay up to date with the master.

Services

In MV3D, the initial remote interface that you will see is the service. These can be remote or local, but should always be assumed to be remote. With a service reference, you can safely make calls to it normally without using callRemote. Services provide interfaces for any number of protocols. Remotely, these interfaces are accessed by an mv3d.net.client.IServiceCon, and therefore calling methods on them is the same regardless of protocol.