Answer the question
In order to leave comments, you need to log in
Can't join user to socket.io room?
код Angular:
.controller('authorizationCtrl', function($scope, multipartForm, $http, $state, $stateParams, authorizationService, categoryService, toastr, socket) {
$scope.signIn = function() {
// hide all errors
authorizationService.signIn($scope.logData).then(function(data) {
socket.emit('login', {
'id': data._id
}, socket);
authorizationService.authenticateUser(data);
$state.go('home.orders', {
id: data._id
});
}, function(err) {
toastr.error('Данні введено не вірно', 'Помилка!');
});
};
});
Код node:
socket.on('login', function(data) {
// data.id = 'room1'
socket.join(data.id);
console.log(socket);
});
В консоль выводит socket:
...
rooms: { '/#MovnATsDFB6jTuKDAAAB': '/#MovnATsDFB6jTuKDAAAB' },
...
но как видите в rooms он не присоединился, в чем собственно проблема может быть?
socket видит emit шлет, помогите : (
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question