site_connect.js to your website you enable a lightweight publish/subscribe transport mechanism. The page contains a extremely lightweight message broker which allows one to route messages from publishers to multiple subscribers.
A Quick Overview
Messages are published to topics. All subscribers to a topic will get the message. A topic is a string, much like a file-path. For example "
truck/001/temperature". A subscriber can directly subscribe to a topic, or use wildcards '
+' and '
+' matches exactly one word between the slashes, and '
#' can be used at the end of a pattern to match all sub-topics.
truck/0001/temperature- Matches the temperature publications of
truck/+/temperature- Matches the
temperaturepublications of all trucks.
+/+/temperature- Matches the
temperaturepublications of all vehicles.
truck/0001/#- Matches all publishes of
0001on all its sub-topics.
Publish/Subscribe in Channel.me
//channel.me/site_connect.js it is possible to subscribe and publish topics on your local page.
site_connect.subscribe(topic, msg_fun, ack_fun)Subscribe to 'topic', when a message arrives which matches topic, the msg_fun callback will be called. The ack_fun callback will be called when the subscription is ready. This is needed because subscribing to topics on the site-connect frame is asynchronous. Returns subscription id.
site_connect.unsubscribe(subscription_id)Unsubscribe from the specified subscription id.
site_connect.publish(topic, msg)Publish a msg under 'topic'.
All topics on the host page begin with the '~/' character. Messages published under this topic are not transferred to the site-connect frame and remain local.
~/site_connect/readyThe site-connect frame is ready. Note that the site connect frame can be loaded independently of the host page.
The site connect scripts loads a separate frame which serves as a connection to the channel.me servers. When a customer agent starts a co-browse or chat session this frame is used to display the interface. Components can be loaded on demand during the lifetime of the host-page. During its lifetime messages can be published. Subscribers can subscribe to these messages by subscribing to the following set of topics.
~/site_connect/readyThe site connect is ready to go and has a customer contact code.
~/site_connect/retryOccasionally, when the channel.me server is too busy the frame is returned without a code. The page is trying to get a new customer contact code.
~/site_connect/errorThe page gave up trying to get a new customer contact code.
~/site_connect/new_codeThe site connect frame gets a new customer contact code. This can happen after a co-browse session.
~pagesession/cobrowsing/startA co-browsing session is started.
~pagesession/cobrowsing/stopA co-browsing session is stopped.
Site-Connect Frame Handling Topics
~pagesession/show_frameShow the site-connect frame. This is done when a chat requested is opened, or another component like the proactive chat request should be made visible.
~pagesession/minimize_frameMinimize the site-connect frame. This is triggered when the user minimises the chat component.
~pagesession/hide_frameCompletely hide the site-connect frame. This is done when the chat session is stopped.
Chat Button Topics
~/site_connect/chat_button/:button_id:/enabledThe chat button with id
:button_id:is enabled. This means there is an agent available to receive an incoming chat message.
~/site_connect/chat_button/:button_id:/disabledThe chat button with id
:button_id:is disabled. This means there is no agent available to receive an incoming chat message.
~pagesession/chat/triggerThe user clicked on a chat button. The message contains the id of the button.
~pagesession/proactive/triggerThe proactive chat was triggered.