Django and Comet
Written by on Wednesday, December 26th, 2007 in Ajax News.
Arena Albionu has written about Django and Comet using the Orbited Python event driven comet server.
The article walks through the hello world of Comet… a chat server. The JavaScript looks like this:
-
-
function processGetPost()
-
{
-
var myajax=ajaxpack.ajaxobj
-
var myfiletype=ajaxpack.filetype
-
if (myajax.readyState == 4)
-
{ //if request of file completed
-
if (myajax.status==200 || window.location.href.indexOf(”http”)==-1)
-
{ //if request was successful or running script locally
-
if (myfiletype==”txt”)
-
alert(myajax.responseText)
-
else
-
alert(myajax.responseXML)
-
}
-
}
-
}
-
-
-
function connect()
-
{
-
var nick = document.getElementById(’nickname’).value;
-
Orbited.connect(chat_event, nick, “/chat”, “0″);
-
ajaxpack.getAjaxRequest(”/join/” + nick + “/”, “”, processGetPost, “txt”);
-
}
-
-
-
chat_event = function(data) {
-
var chat_box = document.getElementById(’box’);
-
var div = window.parent.document.createElement(’div’);
-
div.className = “event”;
-
div.innerHTML = data;
-
chat_box.appendChild(div);
-
chat_box.scrollTop = chat_box.scrollHeight;
-
}
-
-
function send_msg() {
-
var msg = document.getElementById(’chat’).value;
-
var nick = document.getElementById(’nickname’).value;
-
ajaxpack.getAjaxRequest(”/send/” + nick + “/” + msg + “/”, “”, processGetPost, “txt”);
-
}
-
Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/206849560/django-and-comet
Google is set to sign a deal with Japan’s biggest mobile phone operator NTT DoCoMo that will see Google become the default search provider to 48 million NTTDoCoMo customers. The deal will also see NTT DoCoMo switching to Google Apps for the provision of email to it customers.





