diff --git a/reference.html b/reference.html index f7f50e2..feb8388 100644 --- a/reference.html +++ b/reference.html @@ -544,6 +544,70 @@ received from the server (in server sequence number ordering). This is useful fo using Cosmopolite as a key/value store that don't need to interact with the historical messages.

+ +

pin()

+ +

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 on success, or rejects with no arguments if the client is denied access +to write to the subject. If successful, it is passed a single string argument containing a unique +identifier for the pin that can later be passed on unpin().

+ +

A pin is like a message, with some differences: it is +tied to the lifetime of the current instance and +channel, it can be deleted by the publishing client +(by calling unpin(), and it is unordered on the server.

+ +

The pin 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 +onPin callback, it will fire for this pin when it is received back from the +server. You can filter pins by comparing their sender field to the return value of +currentProfile() to avoid processing your own pins.

+ + +

unpin()

+ +

Arguments: +

    +
  1. id: An ID string previously passed to the resolve callback of the promise + returned by pin() or the sender_message_id from the + onPin callback or the return value of getPins().

    +

+ +

Returns: A + +Promise that resolves with no arguments on RPC completion

+ +

Remove a currently active pin. The pin must have been added by this +client, but not necessarily by this instance (the +client library automatically re-adds pins after reconnection).

+ + +

getPins()

+ +

Arguments: +

    +
  1. subject: A valid subject (string, number or object with + specific keys)
  2. +

+ +

Returns: An unordered array of message-like objects. +

+ +

The client library keeps a list of currently active pins +subscriptions. getPins() returns the contents of that cache.

+