Icontem

jQuery HTML5 Websocket or AJAX Chat: jQuery Chat plugin using Websockets or AJAX

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2013-12-09 (3 years ago) RSS 2.0 feedNot enough user ratingsTotal: 522 This week: 1All time: 41 This week: 11Up
Version License JavaScript version Categories
jqh5ajx 1.0.0GNU General Publi...1.0AJAX, jQuery, Chat
Description Author

This object is a jQuery Chat plugin which can use HTML5 Websockets or HTML5 SSE (Server Sent Events) with AJAX Long Polling as fallback in order to fetch updated information from server instead of using old method of regular AJAX calls.

It can send and receive user messages to a server based on Websocket connections or server sent events connections or regular HTTP requests using AJAX.

It can invoke callback functions when a connection with the chat server is opened, when messages are exchanged or when an error happens.

This plugin can also be used in chat applications or wherever we have to call server at regular interval or stay connected with server to get latest information from server as its available on server like updating feed posts or any other contents, or get notifications, etc..

Innovation Award
JavaScript Programming Innovation award winner
December 2013
Winner


Prize: One year Codenvy Developer hosted cloud IDE premium plan
Websocket is a protocol based on HTTP that provides bidirectional communication between browsers and Web servers.

Websocket provides a better solution to implement interactive Web applications, like for instance chat systems, as it can provide a faster means to exchange messages in real time.

This jQuery plugin that can act as a chat client based on Websocket, but it can also fallback to AJAX requests for browsers that do not support Websocket.

Manuel Lemos
Name: PLSCIS PLP <contact>
Classes: 1 package by
Country: India India
Age: ???
All time rank: 422 in India India
Week rank: 14 Up2 in India India Equal
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

Details
Code to initialize object:
var ms = new $('#msgchat').jqh5ajx({ msg_link:server_url, clbk_fnc:'setchatdtls' });

where server_url is the server url to call, and setchatdtls is the callback function. 

Code to send data using websocket:
// use this condition to make sure it is using websocket connection
if(typeof ms.mcevs != 'undefined' && ms.mcevs != null && typeof ms.chattype != 'undefined' && ms.chattype != null && ms.chattype == 'ws') {
    ms.send('text');
}

Code to close websocket connection:
// use this condition to make sure it is using websocket connection
if(typeof ms.mcevs != 'undefined' && ms.mcevs != null && typeof ms.chattype != 'undefined' && ms.chattype != null && ms.chattype == 'ws') {
    ms.close();
}

For handling web-sockets, can use any php web-socket server library like:
1) Ratchet PHP Web-Sockets library (http://socketo.me/)
 OR
2) https://github.com/Devristo/phpws
  Files folder image Files  
File Role Description
Plain text file HandleRequest.php Class Handle HTML5 SSE OR AJAX requests
Plain text file jqh5ajx.js Class Jquery HTML5 ASYNC JS Solution
Accessible without login Plain text file ReadMe.txt Doc. Readme file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:522
This week:1
All time:41
This week:11Up