|
@@ -26,10 +26,14 @@ angular.module('chatServices', [])
|
|
};
|
|
};
|
|
|
|
|
|
service.connect = function(username) {
|
|
service.connect = function(username) {
|
|
|
|
+ service.error = null;
|
|
chatSocket = new WS(jsRoutes.controllers.Application.chat(username).webSocketURL());
|
|
chatSocket = new WS(jsRoutes.controllers.Application.chat(username).webSocketURL());
|
|
chatSocket.onmessage = wrap(function(event) {
|
|
chatSocket.onmessage = wrap(function(event) {
|
|
var message = JSON.parse(event.data);
|
|
var message = JSON.parse(event.data);
|
|
console.log(message);
|
|
console.log(message);
|
|
|
|
+ if(message.error) {
|
|
|
|
+ service.error = message.error;
|
|
|
|
+ }
|
|
if(message.kind != "pong") {
|
|
if(message.kind != "pong") {
|
|
$rootScope.$broadcast('ws:message', message);
|
|
$rootScope.$broadcast('ws:message', message);
|
|
}
|
|
}
|
|
@@ -73,6 +77,9 @@ angular.module('chatServices', [])
|
|
}
|
|
}
|
|
service.messages.push(message);
|
|
service.messages.push(message);
|
|
},
|
|
},
|
|
|
|
+ getError: function() {
|
|
|
|
+ return Connection.error;
|
|
|
|
+ },
|
|
connect: Connection.connect,
|
|
connect: Connection.connect,
|
|
disconnect: Connection.disconnect,
|
|
disconnect: Connection.disconnect,
|
|
isConnected: Connection.isConnected,
|
|
isConnected: Connection.isConnected,
|