ScriptContextInterface

class kanzi::connect::ScriptContextInterface : public MetaObject

Public Functions

inline virtual ~ScriptContextInterface()
virtual bool initialize(AbstractServiceSharedPtr service) = 0

Initialize the context.

Return

true on success.

inline virtual void registerService(const string &identifier, int sessionId)

Register a service to be used within a script.

Registering a service to script context allows accessing its methods, events and runtime-data on a script using notation [ServiceIdentifier]:[method|event|runtimedata-name], e.g. “System:demo.range”.

Parameters
  • identifier: An identifier of a service to be registered.

  • sessionId: Session identifier on SimpleConnectedClientSharedPtr

virtual void reset() = 0

Release resources and context.

inline virtual bool runOnce(const string &script, AbstractServiceSharedPtr service, ConnectedClientProxySharedPtr client)

Run a script.

Return

true if there is more work to do and script should keep running on further iterations.

Parameters
  • script: ECMAScript E5/E5.1 as a string.

  • service: A service to host the script.

virtual shared_ptr<GenericRPCReplyMessage> runScript(const MethodDescription &description, const MessagePackage &message, AbstractServiceSharedPtr session) = 0

Execute a script.

Return

Reply message according to method description or null pointer.

Parameters
  • description: Description of method arguments and return value.

  • message: Arguments for the method.

  • service: Attached service.

inline virtual void unregisterService(const string &identifier)

Unregister a service.

Parameters
  • identifier: An identifier of a service to be unregistered.