1. John Costa
  2. django-socketio-on-dotcloud

Commits

John Costa  committed 4ca017a

current

  • Participants
  • Parent commits 9a2b96d
  • Branches master

Comments (0)

Files changed (4)

File socket/hellodjango/templates/test.html

View file
+<!DOCTYPE HTML>
+<html>
+<head>
+    <script type="text/javascript">
+        function WebSocketTest()
+        {
+            if ("WebSocket" in window)
+            {
+                alert("WebSocket is supported by your Browser!");
+                // Let us open a web socket
+                var ws = new WebSocket("ws://http://socket21-johndotcloud.dotcloud.com:80/echo");
+                ws.onopen = function()
+                {
+                    // Web Socket is connected, send data using send()
+                    ws.send("Message to send");
+                    alert("Message is sent...");
+                };
+                ws.onmessage = function (evt)
+                {
+                    var received_msg = evt.data;
+                    alert("Message is received...");
+                };
+                ws.onclose = function()
+                {
+                    // websocket is closed.
+                    alert("Connection is closed...");
+                };
+            }
+            else
+            {
+                // The browser doesn't support WebSocket
+                alert("WebSocket NOT supported by your Browser!");
+            }
+        }
+    </script>
+</head>
+<body>
+<div id="sse">
+    <a href="javascript:WebSocketTest()">Run WebSocket</a>
+</div>
+</body>
+</html>

File socket/hellodjango/urls.py

View file
 
 # Uncomment the next two lines to enable the admin:
 from django.contrib import admin
+from django.views.generic.simple import redirect_to
+
 admin.autodiscover()
 
 urlpatterns = patterns('',
     ("^chat/", include('chat.urls')),
     url("", include('django_socketio.urls')),
     url(r'^admin/', include(admin.site.urls)),
+    (r'^$', redirect_to, {'url': '/chat'})
 )
 
 if settings.DEBUG:

File socket/supervisord.conf

View file
 [program:websocket]
 #command=/home/dotcloud/env/bin/python /home/dotcloud/current/wsgi.py
 numprocs = 1
-command=/home/dotcloud/env/bin/python /home/dotcloud/env/bin/gunicorn wsgi:application -c /home/dotcloud/current/gunicorn.conf
+#command=/home/dotcloud/env/bin/python /home/dotcloud/env/bin/gunicorn wsgi:server -c /home/dotcloud/current/gunicorn.conf
+command=/home/dotcloud/env/bin/python /home/dotcloud/current/wsgi.py
 redirect_stderr = true
 stdout_logfile = /var/log/supervisor/websocket-supervisor.log

File socket/wsgi.py

View file
 handler = WSGIHandler()
 server = SocketIOServer(bind, handler, resource="socket.io")
 server.serve_forever()
+print "Socket.io env: {0}".format(os.environ.get("socketio", 'Empty'))