
Inherited by BaseNetworkFacade.
Public Member Functions | |
| abstract void | Initialize () |
| Initialize the facade. | |
| void | Shutdown () |
| Non-blocking shutdown. This explicitly just calls Shutdown(false). | |
| abstract void | Shutdown (bool blockUntilComplete) |
| Shuts down the facade. | |
| abstract bool | Login (ITokenSupplier tokenSupplier) |
| Logs in to the network, specifing a delegate that supplies authorization tokens. | |
| bool | Login () |
| [DEPRECATED] Performs login-time initializations, and indications that no authorization system is being used. | |
| abstract void | Logout () |
| Logs out of the network. | |
| abstract NetworkStatus | GetNetworkStatus () |
| Gets the current network status. | |
| abstract NetworkScene | JoinScene (string sceneName, CreateSpatialReplica createEntityDelegate, RemoveSpatialReplica removeEntityDelegate) |
| Joins a scene. | |
| abstract void | FlagForUpdate (ISpatialOriginal localEntity, BooleanArray changedParts) |
| Indicates that the given entity has state changes that need to be propagated to interested peers. | |
| abstract void | FlagForUpdate (ISpatialOriginal localEntity, int changedPartIndex) |
| Indicates that the given entity has a state change that need to be propagated to interested peers. | |
| abstract Vector3 | GetDestination (IDeadReckonable deadReckonable) |
| Returns the destination position for an IDeadReckonable. | |
| abstract void | SnapToDestination (IDeadReckonable deadReckonable) |
| Forces the IDeadReckonable's position and velocity to the current destination values and begins extrapolation. | |
| abstract void | SendCustomMessageToRemoteCopies (ISpatialOriginal localEntity, MemoryStream eventData) |
| Sends a single message directly to all remote replicas of the specified entity. | |
| abstract void | SendCustomMessageToOriginal (ISpatialReplica remoteEntity, MemoryStream eventData) |
| Sends a single message directly to the controlling instance of this entity. | |
| abstract IChatService | CreateChatService () |
| Gets a new chat service instance. | |
| abstract void | StartController< T > (string controllerUniqueName) |
| Start a controller of the given type on the network. The controller must have a constructor that takes a single string argument. | |
| abstract void | StopController< T > (string controllerUniqueName) |
| Stops the controller of the given type. | |
| virtual void | ProcessNetworkState () |
| Performs any regular processing in Badumna that requires synchronisation with the application. | |
| void | CheckForUpdates () |
| Check if any application updates are available. | |
| abstract void | RegisterArbitrationHandler (HandleClientMessage handler, TimeSpan disconnectTimeout, HandleClientDisconnect disconnect) |
| Registers the handler that will be called when this peer receives an arbitration event from another peer. Used by the arbitration server. | |
| abstract IArbitrator | GetArbitrator () |
| Get an IArbitrator instance that can be used to send arbitration events to the aribtration server. Used by arbitration clients. | |
| abstract void | SendServerArbitrationEvent (int destinationSessionId, byte[] message) |
| Sends an event from the arbitration server to the client identified by destinationUserId. This userId must already be known to the arbitration server (i.e. the client must always initiate any arbitration session). | |
| abstract long | GetUserIdForSession (int sessionId) |
| Gets the userId associated with the give sessionId. This is only valid on an arbitration server peer (arbitration clients only have one arbitration session per arbitration server). If the sessionId is unknown this function returns -1. | |
Static Public Member Functions | |
| static void | ConfigureFrom (string fileName) |
| Configure the library using the specified file. | |
| static void | ConfigureFrom (XmlDocument xmlConfig) |
| Configure the library using the passed XmlDocument. | |
| static void | ConfigureFrom (ConfigurationOptions configuration) |
| Configures the library using the options specified in the given ConfigurationOptions object. | |
| static void | UseTunnel (Uri tunnelServer) |
| Switch to the use of a HTTP tunnel. | |
Properties | |
| static NetworkFacade | Instance [get] |
| The singleton instance of the NetworkFacade. | |
| abstract bool | IsInitialized [get] |
| True if the network is initialized. | |
| abstract bool | IsLoggedIn [get] |
| True if login has succeeded. | |
| virtual bool | IsOffline [get] |
| True if the network is unavailable or after a call to ShutDown(). | |
| virtual bool | IsOnline [get] |
| True if the network is available and initialized. | |
| abstract double | OutboundBytesPerSecond [get] |
| Estimated outbound bytes/second; the rate that we're sending data to other peers. This estimate does not include minor local traffic (such as local broadcast messages for discovery) or diagnostic traffic. | |
| abstract double | InboundBytesPerSecond [get] |
| Estimated inbound bytes/second; the rate that we're receiving data from other peers. This estimate does not include minor local traffic (such as local broadcast messages for discovery) or diagnostic traffic. | |
| abstract double | MaximumPacketLossRate [get] |
| Gets the maximum packet loss rate. | |
| abstract double | AveragePacketLossRate [get] |
| Gets the average packet loss rate. | |
| abstract double | TotalSendLimitBytesPerSecond [get] |
| Gets the total send limit in bytes per second. | |
| abstract double | MaximumSendLimitBytesPerSecond [get] |
| Gets the maximum send limit on any given connection in bytes per second. | |
| abstract StreamingManager | Streaming [get] |
| Get the StreamingManager. | |
| abstract PersistenceFacade | Persistence [get] |
| Get the PersistenceFacade. | |
Events | |
| abstract ConnectivityStatusDelegate | OfflineEvent |
| This event is invoked when the network becomes unavailable. (Packets can not be sent). | |
| abstract ConnectivityStatusDelegate | OnlineEvent |
| This event is called when the network becomes available. (Packets can be sent). | |
| EventHandler | RequestShutdown |
| Indicates that the network layer requires the application to shutdown. | |
| EventHandler | RequestShutdownForUpdate |
| Indicates that an update is available and the application should restart to apply them. | |
The NetworkFacade class is a singleton interface to the networking engine. A typical usage scenario is as follows:
NetworkFacade.Instance.Initialize(); // Starts the network thread and performs other initialization NetworkFacade.Instance.Login(tokenSupplier); // Supplies the network with user information / authorizations. NetworkFacade.Instance.JoinScene("SceneName", createEntityHandler, removeEntityHandler); // Joins the given scene. // For each network enabled entity ... foreach (ISpatialOriginal localEntity in localEntities) { // Registers the given entity with the network layer. This will publish the entity, // making it visible to any other peers that have joined the same scene and are nearby. The // scene's CreateEntityDelegate will be called on the remote peers in the scene // to instantiate the given entity. NetworkFacade.Instance.RegisterEntity(localEntity, "entityTag"); } // ... Application loop while (running) { // Do application specific stuff ... // Every time a registered ISpatialOriginal has changed and requires state propagation over the network call : NetworkFacade.Instance.FlagForUpdate(localEntity); // At regular intervals, notify the network engine it is safe to perform any operations on // entities / invoke callbacks. Operations include dispatching updates // for ILocalEntity%s that have been previously passed to NetworkScene.RegisterEntity() and FlagForUpdate(), // and applying updates to ISpatialReplicas. NetworkFacade.Instance.ProcessNetworkState(); } NetworkFacade.Instance.LeaveScene("SceneName"); // Indicates that the user has exited the given scene. NetworkFacade.Instance.Logout(); // Indicates that the user is closing the application. // Possibly Login again or NetworkFacade.Instance.Shutdown(); // Shuts down the network thread and performs other finalization
| void CheckForUpdates | ( | ) |
Check if any application updates are available.
This function will check for any updates to the application package using the mechanism configured in NetworkConfig.xml. If an update is found the RequestShutdownForUpdate event will be triggered.
| static void ConfigureFrom | ( | ConfigurationOptions | configuration | ) | [static] |
Configures the library using the options specified in the given ConfigurationOptions object.
| configuration | The configuration options object. |
| static void ConfigureFrom | ( | XmlDocument | xmlConfig | ) | [static] |
Configure the library using the passed XmlDocument.
| xmlConfig | XML configuration |
| static void ConfigureFrom | ( | string | fileName | ) | [static] |
Configure the library using the specified file.
This call must be made before NetworkFacade.Initialize() is called to ensure that the correct config is used. If no ConfigureFrom(...) overload is called prior to Initialize() then the configuration will be loaded from NetworkConfig.xml in the DLL's directory (defaults will be used if this file cannot be loaded).
See NetworkConfig.xml for details of the configuration file format.
| fileName | Path to the XML config file to use |
| abstract IChatService CreateChatService | ( | ) | [pure virtual] |
Gets a new chat service instance.
Only available after a call to Initialize() and Login().
| abstract void FlagForUpdate | ( | ISpatialOriginal | localEntity, | |
| int | changedPartIndex | |||
| ) | [pure virtual] |
Indicates that the given entity has a state change that need to be propagated to interested peers.
| localEntity | The entity with changed state. | |
| changedPartIndex | The index of the part of state that has changed. |
| abstract void FlagForUpdate | ( | ISpatialOriginal | localEntity, | |
| BooleanArray | changedParts | |||
| ) | [pure virtual] |
Indicates that the given entity has state changes that need to be propagated to interested peers.
| localEntity | The entity with changed state. | |
| changedParts | A BooleanArray with bits set indicating which parts have changed. |
| abstract IArbitrator GetArbitrator | ( | ) | [pure virtual] |
Get an IArbitrator instance that can be used to send arbitration events to the aribtration server. Used by arbitration clients.
| abstract Vector3 GetDestination | ( | IDeadReckonable | deadReckonable | ) | [pure virtual] |
Returns the destination position for an IDeadReckonable.
This can be used in combination with the IDeadReckonable's current Position and Velocity to determine the state of the dead reckoning. With reference to the velocity, if the current position is before the destination then the dead reckoner is interpolating (smoothing). If the current position is after the destination then the dead reckoner is extrapolating.
| deadReckonable |
| abstract NetworkStatus GetNetworkStatus | ( | ) | [pure virtual] |
| abstract long GetUserIdForSession | ( | int | sessionId | ) | [pure virtual] |
Gets the userId associated with the give sessionId. This is only valid on an arbitration server peer (arbitration clients only have one arbitration session per arbitration server). If the sessionId is unknown this function returns -1.
| abstract void Initialize | ( | ) | [pure virtual] |
Initialize the facade.
This method must be called before any other methods on the facade, with the exception of ConfigureFrom().
| abstract NetworkScene JoinScene | ( | string | sceneName, | |
| CreateSpatialReplica | createEntityDelegate, | |||
| RemoveSpatialReplica | removeEntityDelegate | |||
| ) | [pure virtual] |
Joins a scene.
The create and remove entity delegates are called upon the arrival of a new entity and the departure of an old entity respectively. Only entities which are in the same scene and in proximity to a locally registered entity will be passed to these delegates.
| sceneName | The unique name identifying the scene. | |
| createEntityDelegate | Called when a new entity needs to be instantiated into the scene | |
| removeEntityDelegate | Called when an entity in the scene departs. |
| bool Login | ( | ) |
[DEPRECATED] Performs login-time initializations, and indications that no authorization system is being used.
| abstract bool Login | ( | ITokenSupplier | tokenSupplier | ) | [pure virtual] |
Logs in to the network, specifing a delegate that supplies authorization tokens.
Specifies a callback for the system to retrieve authorization tokens and performs login-time initializations. If a user is currently logged in, this function will automatically call Logout() before processing the login operation.
| tokenSupplier | An implementation of a token supplier that will return any required authorization tokens. Calls to the token supplier may be made from a different thread to that which called Login. Tokens returned by the delegate become owned by the network library and should no longer be accessed. The supplier must be usable until either a new Login call is made or Shutdown is called (i.e. Logout won't necessarily release the reference to the delegate immediately because it may need to finalise communication). |
| abstract void Logout | ( | ) | [pure virtual] |
Logs out of the network.
Note that the system may continue using network resources to run distributed processes required by the peer-to-peer network. Call Shutdown() to ensure all network traffic is stopped.
| virtual void ProcessNetworkState | ( | ) | [virtual] |
Performs any regular processing in Badumna that requires synchronisation with the application.
This function must be called regularly by the application so that network events requiring sychronisation can be processed (e.g. it might be called once per frame rendered).
As a rule Badumna will not call application code asynchronously. Particularly, all calls to methods or properties on Badumna interfaces implemented by the application will be made from within ProcessNetworkState(). Calls to delegates registered with Badumna such as the CreateEntityDelegate will also only be made from ProcessNetworkState(). Unless otherwise specified, the only application code that Badumna may invoke asynchronously is delegates that are subscribed to events (e.g. OfflineEvent, OnlineEvent).
| abstract void RegisterArbitrationHandler | ( | HandleClientMessage | handler, | |
| TimeSpan | disconnectTimeout, | |||
| HandleClientDisconnect | disconnect | |||
| ) | [pure virtual] |
Registers the handler that will be called when this peer receives an arbitration event from another peer. Used by the arbitration server.
| abstract void SendCustomMessageToOriginal | ( | ISpatialReplica | remoteEntity, | |
| MemoryStream | eventData | |||
| ) | [pure virtual] |
Sends a single message directly to the controlling instance of this entity.
Events are intended to be used for state changes on entities that are infrequent so they are sent reliably and are guaranteed to be applied in the same order as they are sent. When the message arrives the remote ISpatialOriginal.HandleEvent() method will be called with the given arguments.
| remoteEntity | The entity whose controlling instance should receive the event. | |
| eventData | The event specific data to send. |
| abstract void SendCustomMessageToRemoteCopies | ( | ISpatialOriginal | localEntity, | |
| MemoryStream | eventData | |||
| ) | [pure virtual] |
Sends a single message directly to all remote replicas of the specified entity.
Events are intended to be used for state changes on entities that are infrequent so they are sent reliably and are guaranteed to be applied in the same order as they are sent. When the message arrives the remote ISpatialReplica.HandleEvent() method will be called with the given arguments.
| localEntity | The entity whose replicas should receive the event. | |
| eventData | The event specific data to send. |
| abstract void SendServerArbitrationEvent | ( | int | destinationSessionId, | |
| byte[] | message | |||
| ) | [pure virtual] |
Sends an event from the arbitration server to the client identified by destinationUserId. This userId must already be known to the arbitration server (i.e. the client must always initiate any arbitration session).
| abstract void Shutdown | ( | bool | blockUntilComplete | ) | [pure virtual] |
Shuts down the facade.
Should be called prior to application exit. Initialize()/Shutdown() calls should be paired. Login()/Logout() calls should be paired and occur within an Initialize()/Shutdown() pair. If 'blockUntilComplete' is true this method will not block, but a thread may linger briefly while the network stack performs its finalization. Initialize should not be called again before Shutdown has finished its work (which can only be determined if the call is set to block). Shutdown may try to perform application level operations that have been queued since the last ProcessNetworkState() call. For this reason, Shutdown() should be called prior to other application shutdown operations.
| blockUntilComplete | If true, this method will not return until shutdown has completed. |
| void Shutdown | ( | ) |
| abstract void SnapToDestination | ( | IDeadReckonable | deadReckonable | ) | [pure virtual] |
Forces the IDeadReckonable's position and velocity to the current destination values and begins extrapolation.
| deadReckonable |
| abstract void StartController< T > | ( | string | controllerUniqueName | ) | [pure virtual] |
Start a controller of the given type on the network. The controller must have a constructor that takes a single string argument.
| T | The type of the controller. Must be derived from DistributedController |
| controllerUniqueName | The unique name of the controller. |
| Badumna.Controllers.MissingConstructorException | Thrown when the given type does not have a constructor that takes a single string argument |
| T | : | DistributedController |
| abstract void StopController< T > | ( | string | controllerUniqueName | ) | [pure virtual] |
Stops the controller of the given type.
| T | The type of the controller. Must be derived from DistributedController |
| controllerUniqueName | The unique name of the controller. |
| T | : | DistributedController |
| static void UseTunnel | ( | Uri | tunnelServer | ) | [static] |
Switch to the use of a HTTP tunnel.
| tunnelServer | The tunnel server. |
abstract double AveragePacketLossRate [get] |
Gets the average packet loss rate.
The average packet loss rate.
abstract double InboundBytesPerSecond [get] |
Estimated inbound bytes/second; the rate that we're receiving data from other peers. This estimate does not include minor local traffic (such as local broadcast messages for discovery) or diagnostic traffic.
NetworkFacade Instance [static, get] |
The singleton instance of the NetworkFacade.
abstract bool IsInitialized [get] |
True if the network is initialized.
abstract bool IsLoggedIn [get] |
True if login has succeeded.
virtual bool IsOffline [get] |
True if the network is unavailable or after a call to ShutDown().
virtual bool IsOnline [get] |
True if the network is available and initialized.
abstract double MaximumPacketLossRate [get] |
Gets the maximum packet loss rate.
The maximum packet loss rate.
abstract double MaximumSendLimitBytesPerSecond [get] |
Gets the maximum send limit on any given connection in bytes per second.
The maximum send limit in bytes per second.
abstract double OutboundBytesPerSecond [get] |
Estimated outbound bytes/second; the rate that we're sending data to other peers. This estimate does not include minor local traffic (such as local broadcast messages for discovery) or diagnostic traffic.
abstract PersistenceFacade Persistence [get] |
Get the PersistenceFacade.
abstract StreamingManager Streaming [get] |
Get the StreamingManager.
abstract double TotalSendLimitBytesPerSecond [get] |
Gets the total send limit in bytes per second.
The total send limit in bytes per second.
| abstract ConnectivityStatusDelegate OfflineEvent |
This event is invoked when the network becomes unavailable. (Packets can not be sent).
| abstract ConnectivityStatusDelegate OnlineEvent |
This event is called when the network becomes available. (Packets can be sent).
| EventHandler RequestShutdown |
Indicates that the network layer requires the application to shutdown.
| EventHandler RequestShutdownForUpdate |
Indicates that an update is available and the application should restart to apply them.
1.5.8