TopicFnd

Tinode. TopicFnd

TopicFnd - special case of Tinode.Topic for searching for contacts and group topics.

Constructor

new TopicFnd(callbacks)

Source:
Parameters:
Name Type Description
callbacks TopicFnd.Callbacks Callbacks to receive various events.

Extends

Members

publish

Publishing to TopicFnd is not supported. Topic#publish is overriden and thows an {Error} if called.
Overrides:
Source:

setMeta

setMeta to TopicFnd resets contact list in addition to sending the message.
Overrides:
Source:

Methods

archive(arch) → {Promise}

Archive or un-archive the topic. Wrapper for Tinode#setMeta.
Inherited From:
Source:
Parameters:
Name Type Description
arch Boolean true to archive the topic, false otherwise.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

cancelSend(seqId) → {boolean}

Attempt to stop message from being sent.
Inherited From:
Source:
Parameters:
Name Type Description
seqId integer id of the message to stop sending and remove from cache.
Returns:
Type:
boolean
true if message was cancelled, false otherwise.

contacts(callback, context)

Iterate over found contacts. If callback is undefined, use this.onMetaSub.
Source:
Parameters:
Name Type Description
callback TopicFnd.ContactCallback Callback to call for each contact.
context Object Context to use for calling the `callback`, i.e. the value of `this` inside the callback.

createMessage(data, noEchoopt) → {Object}

Create a draft of a message without sending it to the server.
Inherited From:
Source:
Parameters:
Name Type Attributes Description
data string | Object Content to wrap in a draft.
noEcho Boolean <optional>
If true server will not echo message back to originating session. Otherwise the server will send a copy of the message to sender.
Returns:
Type:
Object
message draft.

delMessages(ranges, hardopt) → {Promise}

Delete messages. Hard-deleting messages requires Owner permission. Wrapper for Tinode#delMessages.
Inherited From:
Source:
Parameters:
Name Type Attributes Description
ranges Array.<Tinode.DelRange> Ranges of message IDs to delete.
hard Boolean <optional>
Hard or soft delete
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

delMessagesAll(hardDel) → {Promise}

Delete all messages. Hard-deleting messages requires Owner permission.
Inherited From:
Source:
Parameters:
Name Type Description
hardDel boolean true if messages should be hard-deleted.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

delMessagesList(list, hardDelopt) → {Promise}

Delete multiple messages defined by their IDs. Hard-deleting messages requires Owner permission.
Inherited From:
Source:
Parameters:
Name Type Attributes Description
list Array.<Tinode.DelRange> list of seq IDs to delete
hardDel Boolean <optional>
true if messages should be hard-deleted.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

delSubscription(user) → {Promise}

Delete subscription. Requires Share permission. Wrapper for Tinode#delSubscription.
Inherited From:
Source:
Parameters:
Name Type Description
user String ID of the user to remove subscription for.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

delTopic(hard) → {Promise}

Delete topic. Requires Owner permission. Wrapper for Tinode#delTopic.
Inherited From:
Source:
Parameters:
Name Type Description
hard Boolean had-delete topic.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to the request.

flushMessage(seqId) → {Message}

Remove one message from local cache.
Inherited From:
Source:
Parameters:
Name Type Description
seqId integer id of the message to remove from cache.
Returns:
Type:
Message
removed message or undefined if such message was not found.

flushMessageRange(fromId, untilId) → {Array.<Message>}

Remove a range of messages from the local cache.
Inherited From:
Source:
Parameters:
Name Type Description
fromId integer seq ID of the first message to remove (inclusive).
untilId integer seqID of the last message to remove (exclusive).
Returns:
Type:
Array.<Message>
array of removed messages (could be empty).

getAccessMode() → {Tinode.AccessMode}

Get user's cumulative access mode of the topic.
Inherited From:
Source:
Returns:
Type:
Tinode.AccessMode
- user's access mode

getDefaultAccess() → {Tinode.DefAcs}

Get topic's default access mode.
Inherited From:
Source:
Returns:
Type:
Tinode.DefAcs
- access mode, such as {auth: `RWP`, anon: `N`}.

getMessagesPage(limit, forward)

Request more messages from the server
Inherited From:
Source:
Parameters:
Name Type Description
limit integer number of messages to get.
forward boolean if true, request newer messages.

getMeta(request) → {Promise}

Request topic metadata from the server.
Inherited From:
Source:
Parameters:
Name Type Description
request Tinode.GetQuery parameters
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

getType() → {String}

Get type of the topic: me, p2p, grp, fnd...
Inherited From:
Source:
Returns:
Type:
String
One of 'me', 'p2p', 'grp', 'fnd', 'sys' or undefined.

invite(uid, modeopt) → {Promise}

Create new topic subscription. Wrapper for Tinode#setMeta.
Inherited From:
Source:
Parameters:
Name Type Attributes Description
uid String ID of the user to invite
mode String <optional>
Access mode. null means to use default.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

isArchived() → {boolean}

Check if topic is archived, i.e. private.arch == true.
Inherited From:
Source:
Returns:
Type:
boolean
- true if topic is archived, false otherwise.

isChannel() → {boolean}

Check if topic is a channel.
Inherited From:
Source:
Returns:
Type:
boolean
- true if topic is a channel, false otherwise.

isGroup() → {boolean}

Check if topic is a group topic.
Inherited From:
Source:
Returns:
Type:
boolean
- true if topic is a group, false otherwise.

isNewMessage(seqId)

Check if the given seq Id is id of the most recent message.
Inherited From:
Source:
Parameters:
Name Type Description
seqId integer id of the message to check

isP2P() → {boolean}

Check if topic is a p2p topic.
Inherited From:
Source:
Returns:
Type:
boolean
- true if topic is a p2p topic, false otherwise.

isSubscribed() → {boolean}

Check if the topic is subscribed.
Inherited From:
Source:
Returns:
Type:
boolean
True is topic is attached/subscribed, false otherwise.

leave(unsubopt) → {Promise}

Leave the topic, optionally unsibscribe. Leaving the topic means the topic will stop receiving updates from the server. Unsubscribing will terminate user's relationship with the topic. Wrapper for Tinode#leave.
Inherited From:
Source:
Parameters:
Name Type Attributes Description
unsub Boolean <optional>
If true, unsubscribe, otherwise just leave.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to the request.

messages(callback, sinceId, beforeId, context)

Iterate over cached messages. If callback is undefined, use this.onData.
Inherited From:
Source:
Parameters:
Name Type Description
callback function Callback which will receive messages one by one. See Tinode.CBuffer#forEach
sinceId integer Optional seqId to start iterating from (inclusive).
beforeId integer Optional seqId to stop iterating before (exclusive).
context Object Value of `this` inside the `callback`.

msgHasMoreMessages(newer)

Check if cached message IDs indicate that the server may have more messages.
Inherited From:
Source:
Parameters:
Name Type Description
newer boolean check for newer messages

msgReadCount(seq) → {Number}

Get the number of topic subscribers who marked this message (and all older messages) as read. The current user is excluded from the count.
Inherited From:
Source:
Parameters:
Name Type Description
seq Number Message id to check.
Returns:
Type:
Number
Number of subscribers who claim to have received the message.

msgReceiptCount(what, seq)

Get the number of topic subscribers who marked this message as either recv or read Current user is excluded from the count.
Inherited From:
Source:
Parameters:
Name Type Description
what String what notification to send: recv, read.
seq Number ID or the message read or received.

msgRecvCount(seq) → {number}

Get the number of topic subscribers who marked this message (and all older messages) as received. The current user is excluded from the count.
Inherited From:
Source:
Parameters:
Name Type Description
seq number Message id to check.
Returns:
Type:
number
Number of subscribers who claim to have received the message.

msgStatus(msg)

Get status (queued, sent, received etc) of a given message in the context of this topic.
Inherited From:
Source:
Parameters:
Name Type Description
msg Message message to check for status.
Returns:
message status constant.

note(what, seq)

Send a read/recv notification
Inherited From:
Source:
Parameters:
Name Type Description
what String what notification to send: recv, read.
seq Number ID or the message read or received.

noteKeyPress()

Send a key-press notification. Wrapper for Tinode#noteKeyPress.
Inherited From:
Source:

noteRead(seq)

Send a 'read' receipt. Wrapper for Tinode#noteRead.
Inherited From:
Source:
Parameters:
Name Type Description
seq Number ID of the message to aknowledge or 0/undefined to acknowledge the latest messages.

noteRecv(seq)

Send a 'recv' receipt. Wrapper for Tinode#noteRecv.
Inherited From:
Source:
Parameters:
Name Type Description
seq Number ID of the message to aknowledge.

p2pPeerDesc() → {Object}

Get description of the p2p peer from subscription cache.
Inherited From:
Source:
Returns:
Type:
Object
peer's description or undefined.

publishDraft(pub, prom) → {Promise}

Add message to local message cache, send to the server when the promise is resolved. If promise is null or undefined, the message will be sent immediately. The message is sent when the The message should be created by Tinode.Topic#createMessage. This is probably not the final API.
Inherited From:
Source:
Parameters:
Name Type Description
pub Object Message to use as a draft.
prom Promise Message will be sent when this promise is resolved, discarded if rejected.
Returns:
Type:
Promise
derived promise.

publishMessage(pub) → {Promise}

Publish message created by Tinode.Topic#createMessage.
Inherited From:
Source:
Parameters:
Name Type Description
pub Object {data} object to publish. Must be created by Tinode.Topic#createMessage
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to the request.

queuedMessages(callback, context)

Iterate over cached unsent messages. Wraps Tinode.Topic#messages.
Inherited From:
Source:
Parameters:
Name Type Description
callback function Callback which will receive messages one by one. See Tinode.CBuffer#forEach
context Object Value of `this` inside the `callback`.

startMetaQuery() → {Tinode.MetaGetBuilder}

Initialize new meta Tinode.GetQuery builder. The query is attched to the current topic. It will not work correctly if used with a different topic.
Inherited From:
Source:
Returns:
Type:
Tinode.MetaGetBuilder
query attached to the current topic.

subscribe(getParamsopt, setParamsopt) → {Promise}

Request topic to subscribe. Wrapper for Tinode#subscribe.
Inherited From:
Source:
Parameters:
Name Type Attributes Description
getParams Tinode.GetQuery <optional>
get query parameters.
setParams Tinode.SetParams <optional>
set parameters.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to the request.

subscriber(uid)

Get cached subscription for the given user ID.
Inherited From:
Source:
Parameters:
Name Type Description
uid String id of the user to query for
Returns:
user description or undefined.

subscribers(callback, contextopt)

Iterate over cached subscribers. If callback is undefined, use this.onMetaSub.
Inherited From:
Source:
Parameters:
Name Type Attributes Description
callback function Callback which will receive subscribers one by one.
context Object <optional>
Value of `this` inside the `callback`.

swapMessageId(pub, newSeqId)

Update message's seqId.
Inherited From:
Source:
Parameters:
Name Type Description
pub Object message object.
newSeqId integer new seq id for pub.

tags()

Get a copy of cached tags.
Inherited From:
Source:
Returns:
a copy of tags

updateMode(uid, update) → {Promise}

Update access mode of the current user or of another topic subsriber.
Inherited From:
Source:
Parameters:
Name Type Description
uid string UID of the user to update or null to update current user.
update string the update value, full or delta.
Returns:
Type:
Promise
Promise to be resolved/rejected when the server responds to request.

userDesc(uid) → {Object}

Get user description from global cache. The user does not need to be a subscriber of this topic.
Inherited From:
Source:
Parameters:
Name Type Description
uid String ID of the user to fetch.
Returns:
Type:
Object
user description or undefined.