Class
PluginConnection
Encapsulates a connection between the current data model and another for plugin communication.
About PluginConnection
Studio plugins run in each Studio data model that the user opens, including
both edit and playtest data models. PluginConnection objects allow these
instances of the same plugin to communicate across data model boundaries.
Messages sent by PluginConnection.SendMessage will be received in
the remote data model via the callback the same plugin registers with
PluginConnection.BindToMessage. Each PluginConnection object can
both send and receive messages while connected, and messages will be received
reliably and in order unless the connection drops (e.g. due to the remote data
model shutting down) before their receipt.
Note that although multiple plugins may share the same PluginConnection
object, they each have their own internal connection; each plugin will receive
only its own messages in its callback to BindToMessage(), even if other
plugins call SendMessage().
Properties 3
Connected
: booleanPluginReadOnlyNotReplicatedWhether thisPluginConnectionobject is still connected.If true, then this
PluginConnectionremains connected to the target data model, and it is still possible to send messages to that data model and receive them from it. If false, then the connection has been lost. Once disconnected,PluginConnectionobjects cannot reconnect, so a value of false here indicates it is now safe to discard thePluginConnectionobject.TargetId
: stringPluginReadOnlyNotReplicatedA unique ID for the target data model.This string contains a globally unique identifier for the target data model, which will be the same for any two plugin connections that target the same data model (even if those connections originate from different data models). This property is immutable.
Type
: PluginConnectionTargetTypePluginReadOnlyNotReplicatedThisPluginConnectionTargetTypedescribes the relationship of the target data model to the current one.This
PluginConnectionTargetTypedescribes the relationship of the target data model to the current data model. For example, a value ofPluginConnectionTargetType.Testmeans that the target data model is a playtest data model spawned from this data model. Alternatively, a value ofPluginConnectionTargetType.Editmeans the target data model is the edit session which spawned this test data model. This property is immutable.
Methods 2
BindToMessage
(callback: Function) → RBXScriptConnectionPluginBinds a callback to thisPluginConnectionto receive messages fromSendMessage().This function binds a callback to this connection, which will be called when the connection receives a message from the current plugin running in the remote data model. The message passed to the callback will be the same as the one the plugin passed to
SendMessage(). ThePluginConnectionwill buffer any messages received before the plugin callsBindToMessage()and deliver them immediately when the plugin does callBindToMessage(). Each plugin may only bind one callback at a time.SendMessage
(message: Variant) → ()PluginSends a payload to the remote data model.This function transmits a string or buffer to the remote data model. The callback registered in
BindToMessage()by the instance of the current plugin running in the remote data model will be called asynchronously with the message as its argument.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.