Coder Social home page Coder Social logo

Comments (3)

nathan815 avatar nathan815 commented on June 28, 2024 5

Turns out the issue was that the room name has to be prefixed with observable- in order for client data to be available. I somehow missed that box in the article.

from android-chat-tutorial.

dilshey avatar dilshey commented on June 28, 2024

did it work
mine still doesn't

from android-chat-tutorial.

luchopb avatar luchopb commented on June 28, 2024

Hi,
I have the same problem, I'm using observable room, and I joined the room with an user, but then when I join with another user in another computer, somehow I don't get the list of users with their .clientData...

var usuario = {
            nombre  : 'VISOR',
            tipo    : 'ALUMNO',
            color   : 'var(--color-base)',
            pin     : '<?php echo $_GET[PIN]; ?>'
        };
        var roomname    = 'aulavirtual-'+usuario.pin;    // make different room for each pin

var drone = new ScaleDrone(CLIENT_ID, {
    data: usuario // Will be sent out as clientData via events
});


console.log("+++ this is my user clientData: ", usuario);

drone.on('open', function (error) {
    if (error) return console.error(error);
    // Connected!
});


// INICIO ROOM
roomname = 'observable-'+roomname;
var room = drone.subscribe(roomname);

room.on('open', function (error) {
    if (error) return console.error(error);
    console.log('Connected to room: '+roomname);
});

room.on('members', m => {
    members = m;
    actualizarListaUsuarios();
    
    console.log("++++ HERE'S THE PROBLEM: ", members);
});


room.on('member_join', member => {

    // SI SOY ALUMNO Y SE METE UN PROFE, HABILITAR AULA
    if (member.clientData.tipo == 'PROFE') {
        if (usuario.tipo == 'ALUMNO') {
            habilitarAula();
            sendData({'seteardatosalumno':true});
        }
    }


    // SUMO NUEVO USUARIO AL ARRAY
    members.push(member);
    actualizarListaUsuarios();
    enviarMensajeAlChat(false, '<i>' + member.clientData.nombre + ' ha ingresado al aula</i>');
});

room.on('member_leave', ({id}) => {

    // borro al miembro de la lista
    const index = members.findIndex(member => member.id === id);
    enviarMensajeAlChat(false, '<i>' + members[index].clientData.nombre + ' ha abandonado el aula</i>');

    if (members[index].clientData.tipo == 'ALUMNO') {
        if (usuario.tipo == 'PROFE') {
            //deshabilitarAula();
        }
    }

    // REMUEVO EL MIEMBRO DE LA LISTA
    members.splice(index, 1);
    actualizarListaUsuarios();
});

When the second user joins, on his end I print the array members and it has only one user, with no clientData. But when I send data to the room, they both get it...

Someone can help me? I don't know what's going on, because this used to work fine, but since some days ago it started failing.

Thank you.

from android-chat-tutorial.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.