cc-everywhere

Class: ChannelMessageListener

Implements

Constructors

Constructor

new ChannelMessageListener(
   sourceChannel, 
   targetProtocolVersion, 
   _filterRequestIdMismatch, 
   protocolHandlersModule?): ChannelMessageListener;

Parameters

Parameter
Type
Default value
sourceChannel
MessageChannel
undefined
targetProtocolVersion
ProtocolVersion
ProtocolVersion.V1_3
_filterRequestIdMismatch
boolean
false
protocolHandlersModule?
ProtocolHandlersModule
undefined

Returns

ChannelMessageListener

Methods

reset()

reset(): void;

Returns

void

didGetMessage()

didGetMessage<T>(message, requestId?): void;

Type Parameters

Type Parameter
T extends MessageType

Parameters

Parameter
Type
message
Message<T>
requestId?
string

Returns

void

Implementation of

IChannelMessengerDelegate.didGetMessage

setTarget()

setTarget(targetChannel, targetChannelInfo): void;

Parameters

Parameter
Type
targetChannel
MessageChannel
targetChannelInfo
TargetChannelInfo

Returns

void

removeTarget()

removeTarget(targetChannel): void;

Parameters

Parameter
Type
targetChannel
MessageChannel

Returns

void

hasTarget()

hasTarget(targetChannel): boolean;

Parameters

Parameter
Type
targetChannel
MessageChannel

Returns

boolean

getTarget()

getTarget(targetChannel): 
  | TargetChannelInfo
  | undefined;

Parameters

Parameter
Type
targetChannel
MessageChannel

Returns

| TargetChannelInfo | undefined

addListenerForTarget()

addListenerForTarget(targetChannel, callback): void;

Parameters

Parameter
Type
targetChannel
MessageChannel
callback
TargetAddedCallback

Returns

void

sendMessage()

sendMessage<T>(targetChannel, message): boolean;

Type Parameters

Type Parameter
T extends MessageType

Parameters

Parameter
Type
targetChannel
MessageChannel
message
| Message<T> | SimpleMessageType

Returns

boolean

sendMessageCompat()

sendMessageCompat<T>(targetChannel, message): boolean;

Sends a message using a message channel that is compatible with older version of SDK.

Type Parameters

Type Parameter
Description
T extends MessageType
The type of the message being sent.

Parameters

Parameter
Type
Description
targetChannel
MessageChannel
message
MessageCompat<T>
The message to send.

Returns

boolean

addListener()

addListener(
   messageType, 
   listener, 
   messageFilter?): void;

Parameters

Parameter
Type
Description
messageType
MessageType
Listener is invoked for incoming message of this message type.
listener
Listener
Callback function that is invoked when there is an incoming message.
messageFilter?
MessageFilter
Filter the incoming message. If this function returns true the element is passed downstream, if it returns false the element is discarded.

Returns

void

removeListener()

removeListener(messageType, listener): void;

Parameters

Parameter
Type
messageType
MessageType
listener
Listener

Returns

void

setRequestId()

setRequestId(requestId): void;

Parameters

Parameter
Type
requestId
string

Returns

void