Interface CommandBridgeAPI
Obtain an instance via CommandBridgeProvider.get().
Use channel(Class) to obtain typed message channels,
server() and connectionState() to query the current
server's identity and connection status, and
onServerConnected(ServerEventListener) or
onServerDisconnected(ServerEventListener) to subscribe to
server lifecycle events on the Velocity proxy.
Methods returning Optional are available only on the
Velocity proxy and return Optional.empty() on backend servers.
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T extends ChannelPayload>
MessageChannel<T> Obtains a typedMessageChannelfor the given payload type.Returns the identifiers of all servers currently connected to the bridge network.Returns the current connection state of this server to the CommandBridge network.onConnectionStateChanged(Consumer<ConnectionState> listener) Subscribes to connection state changes on this server.onServerConnected(ServerEventListener listener) Subscribes to server connection events.onServerDisconnected(ServerEventListener listener) Subscribes to server disconnection events.Returns the player location service for resolving which server a player is connected to.server()Returns the identity of the server this API instance is running on.
-
Method Details
-
channel
Obtains a typedMessageChannelfor the given payload type.- Type Parameters:
T- the payload type; must extendChannelPayload- Parameters:
type- theClasstoken identifying the payload type; used for channel routing- Returns:
- the message channel for sending and receiving payloads of type
T - See Also:
-
server
Platform.ServerTarget server()Returns the identity of the server this API instance is running on.- Returns:
- the
Platform.ServerTargetof the current server, containing its configured identifier and platform type
-
connectionState
ConnectionState connectionState()Returns the current connection state of this server to the CommandBridge network.- Returns:
- the current
ConnectionState - See Also:
-
connectedServers
Returns the identifiers of all servers currently connected to the bridge network.This method is available only on the Velocity proxy. On backend servers, it returns
Optional.empty().- Returns:
- an
Optionalcontaining a snapshot of the connected server IDs if called on the Velocity proxy, or an emptyOptionalon backend servers - See Also:
-
playerLocator
Optional<PlayerLocator> playerLocator()Returns the player location service for resolving which server a player is connected to.This method is available only on the Velocity proxy. On backend servers, it returns
Optional.empty().- Returns:
- an
Optionalcontaining thePlayerLocatorif called on the Velocity proxy, or an emptyOptionalon backend servers - See Also:
-
onServerConnected
Subscribes to server connection events.This method is available only on the Velocity proxy. On backend servers, it returns
Optional.empty()and the listener is not registered.- Parameters:
listener- the listener to invoke when a backend server connects to the bridge network; must not benull- Returns:
- an
Optionalcontaining theSubscriptionon the proxy, or an emptyOptionalon backends - See Also:
-
onServerDisconnected
Subscribes to server disconnection events.This method is available only on the Velocity proxy. On backend servers, it returns
Optional.empty()and the listener is not registered.- Parameters:
listener- the listener to invoke when a backend server disconnects from the bridge network; must not benull- Returns:
- an
Optionalcontaining theSubscriptionon the proxy, or an emptyOptionalon backends - See Also:
-
onConnectionStateChanged
Subscribes to connection state changes on this server.Available on all platforms, unlike the server event methods. The listener is invoked on every state transition.
- Parameters:
listener- the consumer to call with the newConnectionStateon each transition; must not benull- Returns:
- a
Subscriptionthat can be cancelled to stop receiving state change events - See Also:
-