M
M
Mikhailo Poberezhny2016-04-07 01:41:48
Angular
Mikhailo Poberezhny, 2016-04-07 01:41:48

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 question

Ask a Question

731 491 924 answers to any question