Chat - technical overview
The majority of chat actions (such as sending messages, joining a room, etc.) on the live site are performed using AJAX without reloading the page. HTML content is generated almost exclusively by JavaScript on the client side. The server provides the client with data in JSON format.
Windows Communication Foundation
On the server side operate two WCF services - ChatService and ChatSupportService. The client side communicates with those services using HTTP requests and receives data in the JSON format.
JavaScript code for communication with the web services is generated automatically by WCF. You can check if it is generated correctly by visiting the following URL:
<your website URL>/CMSModules/Chat/Services/ChatService.svc/JS
If there isn’t any JavaScript generated on the page, WCF may not be correctly configured. See Configuring Windows Communication Foundation.
jQuery Templates
The client side receives objects with data and generates HTML. To do so, it uses a jQuery plug-in called Templates. Using the templating system on the client side allows chat to work without requesting pages and still offer flexibility similar to Kentico macro language (K#). jQuery Templates documentation and syntax description can be found at https://github.com/BorisMoore/jquery-tmpl.
Templates are saved as transformations with their type set to jQuery. With the module comes a container document type called Chat – Transformations, which holds transformations needed for chat to work. JavaScript objects are passed to the jQuery Template engine along with the transformation text.
To learn more about the templates and how to use them to customize the chat module, refer to Writing transformations for chat.
BBCode parser
The client side also provides BBCode resolving - a JavaScript resolver is used to parse the BBCode tags.