Protocol Services
API Documentation: mv3d.server.network.
In order to accept incoming connections from clients and other servers, MV3D has several special services which have the responsibility of listening for connections and directing them to the appropriate services. In order to be exposed by a protocol, a service must implement an interface for that protocol. In the config file, this is done with the publish setting. On each protocol service, you can use the publish setting with a list of services to be published by that service.
publish: Sim, Login
In code, these can be published using the publish(service) method:
PBServer.publish(Sim)
PB Server
API Documentation: mv3d.server.network.PBServer
This service publishes the Perspective Broker protocol from Twisted. For more information on the PB protocol see the Twisted documentation. This protocol is what MV3D normally uses for all in game data. All information on the game world and objects within it is transmitted via this protocol. The protocol uses RPCs and also includes functionality for sending complex objects over the network and even updating remotely cached complex objects.
Services published using this protocol must define an interface that inherits from twisted.spread.pb.Viewable and define methods that begin with view_ and take a client identifier as the first argument.
HTTP / HTTPs Server
API Documentation: mv3d.server.network.HttpServer
For a standard http or https server, the HttpServer is the service to use. It can host regular web pages (which use Divmod's Nevow templating engine [todo: add link when their website is back]) or JSON RPC interfaces to services. To add regular web pages through the config file, you can use the pages setting:
pages:WebEditor [WebEditor] type=mv3d.server.editor.WebRoot location=webedit/ templateDir=templates/editor
That setting takes a list of section names in the config file which describe the pages to add and where to put them. For JSON RPC interfaces which should subclass JSONRPCPage and define some methods that start with json_ and accept a client specifier as the first argument. You can specify these using the config setting publish.
