Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update websocket chat demo to work when not addressed as localhost.

Turn on draft76 support.
  • Loading branch information...
commit 1b38b58da87f97e388c73fcc2c5c271669382e94 1 parent 3beb8ce
@bdarnell bdarnell authored
Showing with 7 additions and 2 deletions.
  1. +4 −0 demos/websocket/chatdemo.py
  2. +3 −2 demos/websocket/static/chat.js
View
4 demos/websocket/chatdemo.py
@@ -57,6 +57,10 @@ class ChatSocketHandler(tornado.websocket.WebSocketHandler):
cache = []
cache_size = 200
+ def allow_draft76(self):
+ # for iOS 5.0 Safari
+ return True
+
def open(self):
ChatSocketHandler.waiters.add(self)
View
5 demos/websocket/static/chat.js
@@ -50,10 +50,11 @@ var updater = {
socket: null,
start: function() {
+ var url = "ws://" + location.host + "/chatsocket";
if ("WebSocket" in window) {
- updater.socket = new WebSocket("ws://localhost:8888/chatsocket");
+ updater.socket = new WebSocket(url);
} else {
- updater.socket = new MozWebSocket("ws://localhost:8888/chatsocket");
+ updater.socket = new MozWebSocket(url);
}
updater.socket.onmessage = function(event) {
updater.showMessage(JSON.parse(event.data));
Please sign in to comment.
Something went wrong with that request. Please try again.