Explorar o código

Redo logic for websocket redirection

Now we just setup the websocket connection to the websocket enabled one,
but we use port 80 for everything else.
Thomas Dy %!s(int64=11) %!d(string=hai) anos
pai
achega
5f178148ed
Modificáronse 2 ficheiros con 8 adicións e 3 borrados
  1. 6 1
      public/javascripts/chatServices.js
  2. 2 2
      public/javascripts/main.js

+ 6 - 1
public/javascripts/chatServices.js

@@ -50,7 +50,12 @@ angular.module('chatServices', [])
     if(service.status != 'disconnected') return;
     service.error = null;
     service.status = 'connecting';
-    chatSocket = new WS(jsRoutes.controllers.Application.chat(username, getRoom()).webSocketURL());
+
+    var url = jsRoutes.controllers.Application.chat(username, getRoom()).webSocketURL();
+    if(window.location.hostname == "gamenchat.pleasantprogrammer.com" && window.location.port == "") {
+      url = url.replace("gamenchat.pleasantprogrammer.com", "$&:8000");
+    }
+    chatSocket = new WS(url);
     chatSocket.onmessage = wrap(function(event) {
       var message = JSON.parse(event.data);
       if(message.error) {

+ 2 - 2
public/javascripts/main.js

@@ -1,5 +1,5 @@
-if(window.location.hostname == 'gamenchat.pleasantprogrammer.com' && window.location.port != 8000) {
-  window.location = 'http://gamenchat.pleasantprogrammer.com:8000';
+if(window.location.hostname == 'gamenchat.pleasantprogrammer.com' && window.location.port == "8000") {
+  window.location = 'http://gamenchat.pleasantprogrammer.com';
 }
 
 angular.module('taboo', ['chatServices', 'tabooServices'])