Gillius's Programming

GNE High-Level API: ObjectBroker Design

Back to High-Level Design

Description of the ObjectBroker

The ObjectBroker is one of three main parts of the high-level API, and like the ChannelProvider, it can be used seperately outside the Server/Client API, but it becomes most useful when it is integrated with the Server/Client API (which also integrates ObjectBroker with the ChannelProvider).

The ObjectBroker is a way of replicating objects back and forth between two machines. However, only one side of the connection can do the creating of objects. The reason for this is because ObjectBroker handles a unique set of object IDs for all of the objects it is currently managing, and were both sides to create new objects for replication through the ObjectBroker, they may accidently both pick the same ID for two different objects. Once an object has been created, both sides could send update packets, but this may not be desireable depending on the authority model the game uses. And likewise for creating, only one side can be responsible for deleting objects. In server-authoritative games, this is usually OK since the server will be doing all of the creating and managing of the objects, and the clients shoudl be sending requests for their actions to take place on the server.

The ObjectBroker could be useful in other game network types, such as peer-to-peer, but it has no methods for handling object synchronization or conflicting objects. It is simply a system for sending object replications across a GNE connection.

Whereas the mid-level GNE API dealt with sending user-defined Packet objects created from user-defined classes, the high-level API will deal with not only sending packets, but with sending objects. On its own, the ObjectBroker simply acts as creator and handler of ObjectCreation, ObjectUpdate, and ObjectDelete wrapper packets, which wrap a normal packet of the user's choosing. The actions when ObjectBrokers are given packets is defined with the object types which are registered with the broker. The user code will register packet IDs and an object creation method, similar to the system used with PacketParser's registration for custom packets.

When used on its own, the user-code will need to take the packets that the ObjectBroker creates, and send them directly across the desired connections. The remote side needs to capture these packets, and process each of them manually with the ObjectBroker, which will then generate the appropriate events.

However, for the easiest usage of ObjectBroker, the Server/Client API understands the three ObjectBroker packets, and will process these packets automatically without the need of additional user-code. However, the user-code must still decide where to send these packets, but this process will be easier when using the full high-level API because of the ChannelProvider's ability to make groups of connections that will share data through the server. In most cases, the server user-code will be creating the ObjectBroker packets, and will likely want to send them to all players. The GNE Client class will automatically process these packets.

Players

In the Server/Client API, the Players are actually managed and replicated by the ObjectBroker, so these events are treated a little specially in this API, and this means that the ObjectBroker will be required to have some set of registrations so it knows how to replicate players.

Note that the user-code has no obligation to use ObjectBroker even when using the Server/Client API, except for what is required to set up the ObjectBroker to work with its custom PlayerData objects, so if the methods used by the ObjectBroker are not sufficient for sending some or all of its objects, it just simply not choose to use the ObjectBroker or send the ObjectBroker packets when it desires to replicate the objects outside of the ObjectBroker system.

Diagrams

View diagrams of the "server side", or more technically, the side creating the ObjectBroker packets meant for sending to clients.

View the diagram of the "client side" of what happens when the ObjectBroker is given a packet to process.