Переглянути джерело

Mainly expose Chat instead of Connection service

Thomas Dy 11 роки тому
батько
коміт
fe1d1179eb
2 змінених файлів з 5 додано та 2 видалено
  1. 3 0
      public/javascripts/chatServices.js
  2. 2 2
      public/javascripts/main.js

+ 3 - 0
public/javascripts/chatServices.js

@@ -29,6 +29,7 @@ angular.module('chatServices', [])
     chatSocket = new WS(jsRoutes.controllers.Application.chat(username).webSocketURL());
     chatSocket.onmessage = wrap(function(event) {
       var message = JSON.parse(event.data);
+      console.log(message);
       if(message.kind != "pong") {
         $rootScope.$broadcast('ws:message', message);
       }
@@ -72,6 +73,8 @@ angular.module('chatServices', [])
       }
       service.messages.push(message);
     },
+    connect: Connection.connect,
+    disconnect: Connection.disconnect,
     isConnected: Connection.isConnected,
     send: Connection.send
   };

+ 2 - 2
public/javascripts/main.js

@@ -24,8 +24,8 @@ function ViewCtrl($scope, Connection) {
   });
 }
 
-function LoginCtrl($scope, Connection) {
-  $scope.service = Connection;
+function LoginCtrl($scope, Chat) {
+  $scope.service = Chat;
 }
 
 function ChatCtrl($scope, Chat) {