Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No data being sent or received. #3

Open
r21meghashyam opened this issue Apr 23, 2019 · 0 comments
Open

No data being sent or received. #3

r21meghashyam opened this issue Apr 23, 2019 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@r21meghashyam
Copy link

r21meghashyam commented Apr 23, 2019

Following code doesn't generate any errors or warnings, but con.send does not trigger con.on('data',fn) on the remote peer application.

const peer = new Peer();
    
    peer.on('open',(id)=>{
        console.log("Your peer id: "+id);
        firebase.firestore().doc("peers/"+phoneNumber).set({
            phoneNumber,
            id,
            timestamp: Date.now()
        });
        firebase.firestore().collection("peers").onSnapshot(snap=>{

                snap.forEach(doc=>{
                    let data = doc.data();
                    if(data.phoneNumber==phoneNumber)
                        return;
                    console.log(data.id);
                    let conn = peer.connect(data.id,{
                        label: data.phoneNumber,
                        serialization:'json'
                    });
                    
                    
                })
        });

    })
    peer.on("connection",(conn)=>{
      conn.on('open', function() {
        console.log(`Connected to ${conn.peer}`);
        conn.send({ value: 'hello' });
        console.log("Sent");
    });
    conn.on('data', function(data) {
        console.log('Received', data);
    });
    conn.on('error',(error)=>{
        console.log(`Peer error on ${conn.label} (${conn.id}): ${error}`);
    })
    })
    peer.on('close',()=>{
        console.log("Connection was closed");
    })
    peer.on('disconnected',()=>{
        console.log("Got disconnected");
    })
    peer.on('error',(err)=>{
        console.log("Peer error occurred: ",err.type);
    })
@web-mech web-mech added bug Something isn't working help wanted Extra attention is needed labels Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants