question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to send message like whatsapp, telgram, viber or imo just between two person?

See original GitHub issue

Hi, I want to create a messenger app like whatsapp,

  1. First I need to make a list of people connected to my messenger app.
  2. I want to message to one of the person which existed on the list, so I click on its name on the list.
  3. Now I want to chat with him.

Here I dont want message gets broadcast to all people.

So please show me the best secure way.

I’ve done some like below code. I am just created a room only between two person this works well. but problem is when two person for the first time and the same time click each other to go messaging there two diffrent rooms gets create. if they click each other from the list for the first time in different time then it works well.

(async () => {

try {

    const r1 = await AsyncStorage.getItem(userphone + "u-uuuuuuuu-u" + mynumber);
    const r2 = await AsyncStorage.getItem(mynumber + "u-uuuuuuuu-u" + userphone);

    if (r1 !== null || r2 !== null) {
        if (r1 !== null) {
            this.socket.emit("joiningroom", { room: r1 });
            if (this._isMounted) {
                this.setState({ room: r1 });
            }
        } else {
            this.socket.emit("joiningroom", { room: r2 });
            if (this._isMounted) {
                this.setState({ room: r2 });
            }
        }

    } else {

        var ref1 = db.collection('chatrooms').doc(userphone + "u-uuuuuuuu-u" + mynumber);
        var ref2 = db.collection('chatrooms').doc(mynumber + "u-uuuuuuuu-u" + userphone);

        const doc1 = await ref1.get();
        const doc2 = await ref2.get();

        if (doc1.exists || doc2.exists) {

            if (doc1.exists) {
                const room = doc1.data().mbaliotaq;
                this.socket.emit("joiningroom", { room });
                if (this._isMounted) {
                    this.setState({ room });
                }
                await AsyncStorage.setItem(userphone + "u-uuuuuuuu-u" + mynumber, room);
            } else {
                const room = doc2.data().mbaliotaq;
                this.socket.emit("joiningroom", { room });
                if (this._isMounted) {
                    this.setState({ room });
                }
                await AsyncStorage.setItem(mynumber + "u-uuuuuuuu-u" + userphone, room);
            }

        } else {

            const id = userphone + "u-uuuuuuuu-u" + mynumber;
            const room = "mmm" + userphone + "r-rrrrrrrrr-r" + mynumber + "mmm";

            db.collection('chatrooms').doc(id).set({
                mbaliotaq: room
            }).then(() => {
                this.socket.emit("joiningroom", { room });
                if (this._isMounted) {
                    this.setState({ room });
                }
            }).catch(err => {
                console.log(err);
            });
        }
    }

} catch (e) {
    console.log(`Error in async ${e}`);
}

})();

I need a bettter way and a secure way than my solution.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
darrachequesnecommented, Feb 23, 2021

For future readers:

Please see the example here: https://socket.io/get-started/private-messaging-part-1/

1reaction
Vitalii2103commented, Feb 25, 2019

I am not an expert but I think they using p2p connection. Look for something like dat://

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to send message like whatsapp, telegram, viber or imo ...
I am just created a room only between two person this works well. but problem is when two person for the first time...
Read more >
Top 10 WhatsApp Alternative Apps You Can Use - Beebom
Like WhatsApp, Viber lets you make video and voice calls but the app goes one step ahead with its Viber Out feature, which...
Read more >
12 Most Used Messaging Apps - Engadget
12 Most Used Messaging Apps · 1. Messenger · 2. WhatsApp Messenger · 3. WeChat · 4. Line · 5. Viber · 6....
Read more >
The 5 best texting apps in 2022 - Zapier
While many other apps include voice messaging (like WhatsApp, above), Viber makes it just as easy to send a video message for a...
Read more >
Viber - Safe Chats And Calls - Apps on Google Play
Viber is a secure, private, fun messaging and calling app, connecting over a billion people worldwide! With group chats, disappearing messages, reminders, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found