diff --git a/reference.html b/reference.html index fa7677c..18d07d6 100644 --- a/reference.html +++ b/reference.html @@ -430,7 +430,7 @@ require a server response.

Returns: A Promise that resolves with no arguments on success, or rejects with no arguments if the client -is denied access to the subject.

+is denied access to read the subject.

subscribe() creates a subscription on the server to a particular subject. The subscription is tied to our current instance but is re-created @@ -475,6 +475,40 @@ unsubscribe().

A single call to unsubscribe() undoes all calls to subscribe() for the given subject. + +

sendMessage()

+ +

Arguments: +

    +
  1. subject: A valid subject (string, number or object with + specific keys)
  2. +
  3. message: The message data. Any value that JSON can + serialize is valid.
  4. +

+ +

Returns: A + +Promise that resolves with no arguments on success, or rejects with no arguments if the client +is denied access to write to the subject.

+ +

Sends a message to the given subject. The message +contents are serialized and sent to the server (see +architecture). The server adds metadata (sequence number, +timestamp, sender profile ID), stores the message and sends it on to any current +subscribers to the subject, including possibly back to the local +client. Future subscribers can fetch the historical message from the server's storage (as opposed +to a pin which is ephemeral and tied to the current +instance).

+ +

The message may be rejected by server (causing the promise to reject) if the +subject sets writable_only_by and it does not match our +current profile.

+ +

If we are also subscribed to the given subject and have provided an +onMessage callback, it will fire for this message when it is received +back from the server. You can filter messages by comparing their sender field to the return value +of currentProfile() to avoid processing your own messages.

+