我有使用AutobahnJs的套接字工厂。
app.factory('socket', ['$rootScope', function($rootScope) {
var pubsub = new ab.Session(
'wss://site.com:62315',
function(session) {
pubsub.subscribe('455548878', function(topic, data) {
var seder = {};
seder.data = data;
return seder;
});
console.log('New Session Established');
return session;
},
function(code, reason) {
console.log('Websocket connection closed. Code: '+code+'; reason: '+reason);
}
);
return {
pubsub: pubsub
};
}]);
当socket事件时,我需要在控制器中使用object seder(return seder)。怎么办?