Skip to content

Communicator

The communicator is the means by which the Javascript Adaptor talks to Sketchup

Out of the box there are 2 supported communication channels.

  • Communication via iFrame post message (when an iFrame is detected)
  • Communication via the window.sketchup object (when launched from Desktop or a Ruby extension)
  • TenantParent

new Communicator(options, tenants): Communicator

Parameter Type

options

Partial<CommunicatorOptions>

tenants

Tenant[]

Communicator

debug(…args): void

Parameter Type

…args

unknown[]

void


abstract destroy(): void

Should remove any bindings and destroy this communicator

void


abstract registerChannel(channelName, consumer): void

Registers a channel name and a function to consume data from that channel

This is called internally by the bootstrapping mechanism

Parameter Type Description

channelName

string

the channel to register

consumer

(data) => void

the consumer

void


registerTenantIFrame(options): void

Registers a tenant to this communicator. This allows child iFrames to use the JSA directly

Parameter Type Description

options

TenantOptions

the tenant options

void


abstract removeChannel(channelName): void

Removes a channel by name. Called during disconnection to ensure that there are no dangling callback executions

Parameter Type Description

channelName

string

the channel to remove

void


removeTenant(tenant): void

Removes the tenant from this communicator

Parameter Type Description

tenant

Tenant

the tenant

void

TenantParent.removeTenant


abstract sendOnChannel(channelName, data, tenantID?): void

Sends a message on a given channel

Parameter Type Description

channelName

string

the name of the channel

data

unknown

the data that should be sent

tenantID?

string

the ID of the tenant (if any)

void

TenantParent.sendOnChannel


updateOptions(options): void

Parameter Type

options

Partial<CommunicatorOptions>

void