Method

allocate(chatId) → SparkCommunications.MessageStorageInterface.MessageStorage

Allocates the storage object for a particular chat.

Parameter

Name Type Optional Description

chatId

string

 

The chat for which to allocate storage.

Returns

SparkCommunications.MessageStorageInterface.MessageStorage 

An object containing the functions needed to store and access messages in a chat.

Abstract types

static

GetMessageFunction(message) → SparkCommunications.Messenger.ChatMessage

A function which unwraps an object from the chat list to produce a SparkCommunications.Messenger.ChatMessage. This function undoes SparkCommunications.MessageStorageInterface.NewMessageFunction, such that GetMessageFunction(NewMessageFunction(x)) === x for all x.

Parameter

Name Type Optional Description

message

any

 

The message to unwrap.

Returns

SparkCommunications.Messenger.ChatMessage 

The original ChatMessage which had been wrapped.

static

GetMessagesFunction(message) → any

A function which takes the message list and applies a transform prior to returning it. This can be used to perform tasks such as freezing or filtering the message list.

Parameter

Name Type Optional Description

message

Array of any

 

The message list to transform.

Returns

any 

The message list in any form the client may want.

static

MessageStorage  Object

A structure to encapsulate the data associated with message storage for a single chat. This comprises an array to contain the messages, accessor functions to get data in and out of messages, and a global accessor function to apply global effects to the array.

Properties

Name Type Optional Description

storageArray

Array of any

 

An array in which to store the messages for a chat. The messages will be sorted in order of messageId. The type of objects in the array will be the type returned by newMessage.

newMessage

SparkCommunications.MessageStorageInterface.NewMessageFunction

 

A function which wraps a SparkCommunications.Messenger.ChatMessage to produce an object which will be stored in the chat list. This allows a client to associate custom data with a chat message.

getMessage

SparkCommunications.MessageStorageInterface.GetMessageFunction

 

A function which unwraps a wrapped SparkCommunications.Messenger.ChatMessage to produce the original SparkCommunications.Messenger.ChatMessage. This undoes the effects of newMessage.

getMessages

SparkCommunications.MessageStorageInterface.GetMessagesFunction

 

A function which applies a transform to the message list prior to returning it.

static

MessageStorageAllocator(chatId) → SparkCommunications.MessageStorageInterface.MessageStorage

A function which allocates the storage object for a specific chat.

Parameter

Name Type Optional Description

chatId

string

 

The identifier of the chat for which storage for messages must be allocated.

Returns

SparkCommunications.MessageStorageInterface.MessageStorage 

The return value is used for the client-visible version of a chatMessage. It can be of any type.

static

NewMessageFunction(message) → any

A function which wraps a SparkCommunications.Messenger.ChatMessage to produce an object which will be stored in the chat list. This allows a client to associate custom data with a chat message.

Parameter

Name Type Optional Description

message

SparkCommunications.Messenger.ChatMessage

 

The message to wrap.

Returns

any 

The return value is used for the client-visible version of a chatMessage. It can be of any type.