0
난 내가 사용자가 내 응용 프로그램에서 연결하거나 분리 할 때 서버에서 호출하는 방법을 가지고 각 서비스를각도 클라이언트
(function() {
//'use strict';
app.service('PrivateChatService', ['$rootScope', '$location', function PrivateChatService($rootScope, $location){
var online_users = [];
var proxy = $.connection.chatHub;
return {
addOnlineUser:
proxy.client.newOnlineUser = function (user) {
var newUser = ({
connectionId: user.ConnectionId,
UserName: user.UserName
});
online_users.push(newUser);
$.connection.hub.start()
},
removeOfflineUser: proxy.client.onUserDisconnected = function (id, user) {
var index = 0;
//find out index of user
angular.forEach(online_users, function (value, key) {
if (value.connectionId == id) {
index = key;
}
})
online_users.splice(index, 1);
$.connection.hub.start()
},
}
}])})();
다음
내가되고 싶은 컨트롤러 메소드를 가지고 서버가 newOnlineUser를 호출하면 시작됩니다.
PrivateChatService.newOnlineUser(function (user) {
$scope.online_users.push(newUser);
console.log("newOnlineUser finished");
});
제 질문은 그렇습니다. 생성 된 프록시를 사용하여 만들 수 있습니까 아니면 내가 익숙하지 않은 그 방법에 대한 생성되지 않은 프록시 액세스를 사용해야합니다. 생성 된 프록시와
내가 그것을 아무도 응답하지 않기 때문에 컨트롤러 범위