Skip to main content

SpectaclesMobileKitSession

Class

Spectacles Mobile Kit session allows you to initiate the connection to peer, and send data.

  • Snapchat: not supported
  • SPECS: fully supported
  • Camera Kit Web: not supported
  • Camera Kit Mobile: not supported
  • SnapchatNot supported — Available on SPECS only
  • SPECSFully supported
  • Camera Kit WebNot supported — Available on SPECS only
  • Camera Kit MobileNot supported — Available on SPECS only

Platform details

  • Snapchat — Not supported — Available on SPECS only.

  • SPECS — Fully supported.

  • Camera Kit Web — Not supported — Available on SPECS only.

  • Camera Kit Mobile — Not supported — Available on SPECS only.

Spectacles Mobile Kit session allows you to initiate the connection to peer, and send data.

Index

Extends

Properties

isConnected

readonly isConnected: boolean

SPECS

True if we’re connected to the peer.


onConnected

readonly onConnected: event0<void>

SPECS

Notified when the connection to the peer is established and ready.


onDisconnected

readonly onDisconnected: event0<void>

SPECS

Triggered when the connection to the peer is severed. The session is no longer valid and must be re-created.


onError

readonly onError: event1<string, void>

SPECS

Triggered if the session fails to start (e.g. permission denied or the companion-bridge service rejected the request). The session is no longer valid and must be re-created.

Methods

close()

close(): void

SPECS

Disconnect and stop the session. Session object will be invalid after this call and will need to be re-created.

Returns

void


getTypeName()

static getTypeName(): TypeName<SpectaclesMobileKitSession>

SPECS

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<SpectaclesMobileKitSession>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

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

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

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

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame


sendData()

sendData(data): void

SPECS

Use sendData() to send a one-way message to the connected mobile app. This is a fire-and-forget operation, no response is expected.

Parameters

ParameterType
datastring

Returns

void


sendRequest()

sendRequest(data): Promise<string>

SPECS

Send a request expecting a response from the peer. Returns a promise with the response.

Parameters

ParameterType
datastring

Returns

Promise<string>


start()

start(): void

SPECS

Initialize the session before interacting with the app. Ensure that all callbacks and events are configured prior to calling this method. This action creates the session and begins listening for incoming connections.

Returns

void


startSubscription()

startSubscription(data, onError): event1<string, void>

SPECS

Start a subscription, multiple responses can be sent by the peer. Returns the subscription event. onError will be called if the subscription is cancelled by peer.

Parameters

ParameterType
datastring
onError(error) => void

Returns

event1<string, void>


stopSubscription()

stopSubscription(id): void

SPECS

Stop the subscription.

Parameters

ParameterType
idevent1<string, void>

Returns

void