Communication Ring

An example of using the Communication Ring within the Python environment can be found in the Master Class example script called “”.

class lwsdk.LWComRing(*args)

Bases: object

Proxy of C++ PCore::LWComRing class

 decodeData(char format, PyObject data) → PyObject

Data values encoded with the LWComRing::encodeData() method can be extracted using this method. The method returns a Python sequence that contains each decoded element.

Please refer to the provided example Python plug-in "" for an example of its usage.

 encodeData(char format, PyObject data_array) → PyObject

Data values that you wish to include in any events you create can be marshalled using this method. The example Python plug-in "" employs this method.

LWComRing::encodeData() is intended to mirror the comringencode() function that is available in LScript, and it follows the same formatting. Refer to the LScript v2.7 release notes in the LWSDK for a full description.

The method returns an opaque pointer to allocated memory suitable for transport.

 releaseData(PyObject data)

Data marshalled with the LWComRing::encodeData() method must be provided to this method for disposal. Only the script that actually called LWComRing::encodeData() should invoke this method to release resources, typically immediately following a call to LWComRing::ringMessage().

 ringAttach(char topic, LWInstance pidata, PyObject function) → int

This method is used to attach to, or create, a communication channel on a specified topic. If your intent is to create a new channel, then you should ensure that the topic is unique within the system. Otherwise, an existing topic with that name will be joined.

In order to uniquely identify each participant, some instance data is required. In terms of Python, you should use your self instance data for the pidata argument. Please see the provided example Python plug-in "" for an example of this approach.

Finally, when events arrive on your channel, they will be routed to the provided Python function. Again, "" provides an example of this callback mechanism.

The return value of the method indicates the success (1) or failure (0) of the attachment or creation of the communication channel.

 ringDetach(char topic, LWInstance pidata)

You may detach from an existing topic using this method. The pidata value should be the same value you used when you attached/created the communication channel. In the case of Python, this will typically be your self instance pointer.

If you are the last participant in the indicated topic, the communication channel will be destroyed automatically.

 ringMessage(char topic, int eventCode, void eventData)

Broadcasts a message on the communication channel with the indicated topic. The eventCode value is any integer value you may wish to define, and the eventData value should either be the return value of the LWComRing::encodeData() method, or None.

Previous topic

Global Classes

Next topic

PCore Console

This Page