Gmail Chat Implementation

Today i implemented gmail chat window , not an ajax chat with a chat server, but its client side implementation.
Here you can see the demo: http://www.sajithmr.com/gtalk/
Take this link in a new tab or window, and take any other website without closing it.
After 3 seconds , (Consider it as a new chat message arrived situation) you can see the google chat notification sound , and title changing. (I didn’t get the actual gtalk notification sound, so i used windows notify.wav file )
You know google (gmail) implemented its sound notification is via swf object. Here me too done the same.
I wrote two function to check whether the browser is in focus or not.
Here is the functions:
function lostFocus()
{
document.title = 'Sajith M.R Says...';
state = 'nonfocus';
played = 0 ;
changeColorRed();
alterTitle();
}
function gotFocus()
{
document.title = 'Gmail Inbox(1)';
state = 'focus';
played = 0 ;
}
The alterTitle() function calls in 3 seconds setTimeOut manner.
function alterTitle()
{
if(state =='nonfocus')
{
if ( document.title == 'Gmail Inbox(1)')
{
if(played == 0)
{
soundManager.play('notify');
played = 1;
}
document.title = 'Sajith M.R Says...';
}
else
document.title = 'Gmail Inbox(1)';
setTimeout("alterTitle()",3000);
}
}
The soundmanager.js file handles the swf flash object and sound triggering.
<script type=”text/javascript” src=”script/soundmanager.js”></script>
These three simple scripts together created this demo: http://www.sajithmr.com/gtalk/
If you want the whole source code , mail me: admin@sajithmr.com
Comment Please …
Regards
Sajith.M.R
http://www.sajith.name
- Gmail Architecture
- Upload Files Like Gmail
- Gmail Chat Implementation
|
|
|
|
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!


May 7th, 2008 at 7:27 pm
This is cool implementation in the client side.
June 16th, 2008 at 6:16 pm
Hi,
I looking for hints to implement a gmail like chat, and reading your post has been very informative. Thanks a lot for such a good break of the functionality. It would be very kind of you, if you can send the source code for the gtalk demo you have put on your website.
Thanks a lot.
Regards,
vika
June 16th, 2008 at 8:02 pm
Hey Vikas,
Here is the full source code of client side implementation .
(Not the sever side)
http://www.sajithmr.com/downloads/gtalk.zip
Regards
Sajith
July 20th, 2008 at 10:26 pm
Hello:
What need your code for work like an real chat?…AJAX?
I want put on GMAIL CHAT on my blog…I will thank your help please.
Thanks and Congratulations.
July 20th, 2008 at 11:14 pm
@Leonardo Parada
Hello, i dont have gmail full chat code. If you want to put a gmail chat on your blog, you can use google widget for that purpose, no need to code yourself. Gtalk widget for any blog is currently available.
Regards
Sajith
July 30th, 2008 at 2:36 pm
Hi
How gmail chat get value from another client or user side windows value .Thats what icant under stand..and how its working . you were discuss about only title bar
message and focus changing.
Colud u explain breifly please..
Thanks & Regards
R.Mohamed anifa