site_connect.js to your website.
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, message_func, acknowledge_func)Subscribe to
topic, when a message arrives which matches topic, the
message_funccallback will be called. The
acknowledge_funccallback will be called when the subscription is ready. This is needed because subscribing to topics on the site-connect frame is asynchronous. Calling
subscribereturns subscription id.
site_connect.unsubscribe(subscription_id)Unsubscribe from the specified
site_connect.publish(topic, msg)Publish a
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.
Stopping a Cobrowse Session.
It is possible to stop an ongoing cobrowse session by enforcing a stop. This function signals the communication frame, and stops sending page updates to the channel.me server. The cobrowsing session will stop and the agent is notified. When the session is stopped the
~pagesession/cobrowsing/stop message is published via the publish subscribe api.