Skip to content

Commit

Permalink
Update websocket chat demo to work when not addressed as localhost.
Browse files Browse the repository at this point in the history
Turn on draft76 support.
  • Loading branch information
bdarnell committed Jan 22, 2012
1 parent 3beb8ce commit 1b38b58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions demos/websocket/chatdemo.py
Expand Up @@ -57,6 +57,10 @@ class ChatSocketHandler(tornado.websocket.WebSocketHandler):
cache = [] cache = []
cache_size = 200 cache_size = 200


def allow_draft76(self):
# for iOS 5.0 Safari
return True

def open(self): def open(self):
ChatSocketHandler.waiters.add(self) ChatSocketHandler.waiters.add(self)


Expand Down
5 changes: 3 additions & 2 deletions demos/websocket/static/chat.js
Expand Up @@ -50,10 +50,11 @@ var updater = {
socket: null, socket: null,


start: function() { start: function() {
var url = "ws://" + location.host + "/chatsocket";
if ("WebSocket" in window) { if ("WebSocket" in window) {
updater.socket = new WebSocket("ws://localhost:8888/chatsocket"); updater.socket = new WebSocket(url);
} else { } else {
updater.socket = new MozWebSocket("ws://localhost:8888/chatsocket"); updater.socket = new MozWebSocket(url);
} }
updater.socket.onmessage = function(event) { updater.socket.onmessage = function(event) {
updater.showMessage(JSON.parse(event.data)); updater.showMessage(JSON.parse(event.data));
Expand Down

0 comments on commit 1b38b58

Please sign in to comment.