Lens Scripting API

    Class RemoteServiceModule

    Provides access to Snap authorized remote services.

    Hierarchy (View Summary, Expand)

    Index

    Properties

    name: string

    The name of the Asset in Lens Studio.

    uniqueIdentifier: string

    Methods

    • Wearable Only

      The createWebAPISocket(endpoint, params) method initiates a WebSocket connection with the specified endpoint and the specified params to the Snap authorized remote services. Returns a WebSocket object that can be used to send and receive messages from the server.

      Syntax

      createAPIWebSocket(endpoint, params)
      
      • endpoint Defines the Snap authorized remote service endpoint to which to establish the WebSocket connection.
      • params Defines the parameters that will be used to establish the connection.

      Example

      //@input Asset.RemoteServiceModule remoteServiceModule
      var remoteServiceModule = script.remoteServiceModule

      // Create WebSocket connection.
      let socket = script.remoteServiceModule.createAPIWebSocket("real_time", {"api-token" : "token", "api-example" : "realtime=v1", "model": "model"});

      // Listen for the open event
      socket.onopen = (event) => { print("Socket opened"); };

      // Listen for messages
      socket.onmessage = async (event) => { print("Socket message"); };

      // Listen for the close event
      socket.onclose = (event) => { print("Socket closed"); };

      Parameters

      • endpoint: string
      • params: any

      Returns WebSocket

    • Experimental Wearable Only

      Deprecated. This method has been moved to InternetModule.

      Parameters

      Returns void

    • Wearable Only

      Deprecated. This method has been moved to InternetModule.

      Parameters

      • request: string | Request
      • Optionaloptions: any

      Returns Promise<Response>

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Wearable Only Camera Kit

      Get a DynamicResource to be used with RemoteMediaModule from mediaUrl.

      Parameters

      • mediaUrl: string

      Returns DynamicResource

    MMNEPVFCICPMFPCPTTAAATR