1
0
Эх сурвалжийг харах

Mainly expose Chat instead of Connection service

Thomas Dy 11 жил өмнө
parent
commit
fe1d1179eb

+ 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) {