Now4realSubjectUpdate

Now4realSubjectUpdate

This class is used to notify about updates to a subscribed subject.

Constructor

new Now4realSubjectUpdate()

You cannot use this constructor directly. Interact with instances of this class through subjectUpdateCallback.

Members

(readonly) data :Object

An object that contains the update payload.

(readonly) timestamp :number

The number of milliseconds since the Unix Epoch.

(readonly) type :string

The name of the subject to which the update belongs.

Type Definitions

AuthorizationUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"AUTHORIZATION"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
chatView boolean

true if it's possible to subscribe to the list of chat messages of the current pagechat ("LIST_CHAT_MESSAGES") and the other chat related subjects ("COUNTER_CHAT_MESSAGES", "COUNTER_CHAT_TYPING", "LIST_CHAT_TYPING"). false otherwise.

chatPost boolean

true if it's possible to post or delete a message in the current pagechat and, in case of custom authentication, to notify the Now4real cloud of the start of typing of the current authenticated user in the current pagechat. false otherwise.

siteCounterView boolean

true if it's possible to subscribe to all the real-time counters and analytics at site level ("COUNTER_SITE_VIEWERS", "COUNTER_SITE_CHATTERS", "HEATMAP_SITE_VIEWERS"). false otherwise.

pageCounterView boolean

true if it's possible to subscribe to all the real-time counters and analytics at page level ("COUNTER_PAGE_VIEWERS", "COUNTER_PAGE_CHATTERS", "HEATMAP_PAGE_VIEWERS", "RANKING_PAGE_VIEWERS", "RANKING_PAGE_CHATTERS"). false otherwise.

ConnectionStatusUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"CONNECTION_STATUS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
status string

A string representing the current state of the connection between the client and the Now4real cloud.

  • "CONNECTED" - The client is connected to the Now4real cloud.
  • "DISCONNECTED" - The client is currently disconnected from the Now4real cloud. It will automatically try to reconnect.
  • "DISCONNECTED:CONFIG_CHANGED" - The client was disconnected from the Now4real cloud because the configuration of the current site was changed. A page reload is required in order for the changes to take effect.
  • "DISCONNECTED:CREDIT_EXHAUSTED" - The client was disconnected from the Now4real cloud because the credit for the current site is exhausted. The API will no longer work until some credit is available again.
  • "DISCONNECTED:JWT_EXPIRED" - The client was disconnected from the Now4real cloud because the JWT used for the custom authentication is expired. A page reload is required in order to provide to the API a valid JWT token.
  • "DISCONNECTED:UNSUPPORTED_CLIENT" - The client was disconnected from the Now4real cloud because the current client version is no more supported. A page reload is required in order to get the latest version.
  • "DISCONNECTED:UNSUPPORTED_BROWSER" - The client was disconnected from the Now4real cloud because the current browser is no more supported.

CounterUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

The name of the counter subject to which the update belongs.

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
value string

A string representing the updated counter subject value.
When the value is greater than 999, a rounded version of the value will be used, as shown below.

Counter range Exact value Counter example Value example
1-999 yes 128 "128"
1,000-999,999 no 1,635 "1.6K"
1,000,000 - 999,999,999 no 24,252,000 "24M"
Etc.

HeatmapUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

The name of the heatmap subject to which the update belongs.

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
country string

The two-letter ISO 3166-1 alpha-2 code of the country.

intensity number

A number, from 0 to 1, representing the quantity of viewers from this country who are present in the current Page Context or Site Context. This should not be considered as a percentage but instead as a score.

LoginStatusUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"LOGIN_STATUS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Attributes Description
status string
  • "AUTHENTICATED" - The user has been successfully authenticated within the current browser.
  • "NOT_AUTHENTICATED" - The user has logged out from Now4real within the current browser.
user CurrentUser <optional>

The authenticated user.
(Only available if status is "AUTHENTICATED").

persistent boolean <optional>

false if the custom authentication is being used or, in case of social login, if there are restricted privacy settings on the user browser, which prevent the library from saving the authentication object into the local storage. In that case, the login will not be remembered across page navigations. true otherwise.
(Only available if status is "AUTHENTICATED").

MessageListUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"LIST_CHAT_MESSAGES"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Attributes Description
action string
  • "ADD" - The message is added to the message list.
  • "UPDATE" - The message is updated in the message list.
  • "REMOVE" - The message is removed from the message list (messages should be removed after their expiry, which is controlled by the Now4real cloud because they are ephemeral).
id string

The unique identifier of the message.

message string

The message body.

author User

The user who sent the message.

time number

The number of milliseconds from the Unix Epoch to the time the message was sent.

isMine boolean

Indicates whether the message was sent by the current Now4real user.

deleted string <optional>

A string indicating if the message was deleted and, in that case, by whom.

  • "BY_AUTHOR" - The message has been deleted by the author.
  • "BY_ADMINISTRATOR" - The message has been deleted by the administrator of the site.
  • "BY_MODERATOR" - The message has been deleted by a moderator of the pagechat.
  • "BY_NOW4REAL" - The message has been deleted by the Now4real team.
  • "UNKNOWN" - The author of the deletion is unknown.
repliesTo object <optional>

The message to which this replies to.

Properties
Name Type Attributes Description
id string

The unique identifier of the message.

message string

The message body.

author User

The user who sent the message.

time number

The number of milliseconds from the Unix Epoch to the time the message was sent.

isMine boolean

Indicates whether the message was sent by the current Now4real user.

deleted string <optional>

A string indicating if the message was deleted and, in that case, by whom.

ParametersUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"PARAMETERS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
messageMaxLength number

The maximum number of characters that can be posted as a single message.

messageMaxLengthModerator number

The maximum number of characters that can be posted by a Moderator as a single message.

messageMaxLengthGuest number

The maximum number of characters that can be posted by a Guest as a single message.

messageDurationValue number

The value of the residence time of a chat message in the current pagechat before disappearing. This value reflects the one configured in the Dashboard.

messageDurationUnit string

The measuring unit of the residence time of a chat message in the current pagechat before disappearing. It can be one of the following: "WEEKS", "DAYS", "MINUTES", or "HOURS". This unit reflects the one configured in the Dashboard.

chatStatus string

A string representing the status of the current pagechat.

  • "ENABLED" - The current pagechat is enabled.
  • "DISABLED_BY_MODERATOR" - The current pagechat has been disabled by a Moderator, no messages can be posted until the reactivation.
  • "DISABLED_BY_ADMINISTRATOR" - The current pagechat has been disabled by the Moderator, no messages can be posted until the reactivation.
clickableLinks string

A string indicating which type of links are clickable in the current pagechat. This won't apply to messages posted by Moderators or Guests.

  • "ALL" - Any link is clickable.
  • "INTERNALS" - Only internal links (those pointing to the site or to any of its subdomains) are clickable.
gifsStatus string

A string indicating whether GIFs are enabled in the current pagechat and, if yes, which type of images can be shown. The Now4real cloud uses GIPHY APIs to moderate the sent GIFs.

  • "DISABLED" - GIFs are disabled.
  • "G" - GIFs are enabled. Can be shown images that are broadly accepted as appropriate and commonly witnessed by people in a public environment.
  • "PG" - GIFs are enabled. Can be shown images that are commonly witnessed in a public environment, but not as broadly accepted as appropriate.
  • "PG-13" - GIFs are enabled. Can be shown images that are typically not seen unless sought out, but still commonly witnessed.
  • "R" - GIFs are enabled. Can be shown images that are typically not seen unless sought out and could be considered alarming if witnessed.

PollStatusUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"POLL_STATUS"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
closed boolean

Indicates whether the poll is closed or not.

question string

The question of the poll.

PollUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"POLL"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
closed boolean

Indicates whether the poll is closed or not.

question string

The question of the poll.

answers Array.<PollAnswer>

An array containing the possible answers for the poll, each accompanied by the percentage of votes received.

votesCount string

The total number of voters for the poll.

multipleChoice boolean

Indicates whether the poll allows multiple choices or not.

startDate number

The number of milliseconds from the Unix Epoch to the time the poll was created.

RankingUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

The name of the ranking subject to which the update belongs.

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
action string
  • "INIT" - The initial snapshot of the ranking has been completely received.
  • "ENTER" - A page has entered the ranking.
  • "UPDATE" - The page has changed its position in the ranking.
  • "LEAVE" - The page has left the ranking.
key string

The Context that uniquely identifies the page.

position number

The zero-based position index of the page in the ranking.

url string

The full URL of the page.

title string

The page title, if available, otherwise the Page Context.

users string

The counter value, following the same rules of the CounterUpdate value.

isCurrentPage boolean

Indicates whether the page is the same as the one in which the library is working.

TypingListUpdate :Now4realSubjectUpdate

Properties:
Name Type Description
type string

"LIST_CHAT_TYPING"

timestamp number

The number of milliseconds since the Unix Epoch.

data object
Properties
Name Type Description
action string
  • "START" - The user has started typing a message for the current pagechat.
  • "STOP" - The user has stopped typing a message for the current pagechat.
user User

The user who has started or stopped typing.