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

How to make a one-to-one channel? #175

Closed
d2rk opened this issue May 29, 2016 · 12 comments
Closed

How to make a one-to-one channel? #175

d2rk opened this issue May 29, 2016 · 12 comments

Comments

@d2rk
Copy link

d2rk commented May 29, 2016

How can one create a one-to-one channel and then be able to find it from the context in order to send a message?

On this moment, I'm using group channel for such purpose but it looks to me not the right way to go. Another problem is to identify the user to make a unique channel.

@andrewgodwin
Copy link
Member

If you want to make an externally-identifable channel that points to a particular user, a Group is exactly what you need - consider if the user is logged in on multiple tabs or machines. Groups, in general, are the way to make reply_channels externally predictable as you can link them into a Group with a known name pattern.

@dennissheppard
Copy link

I'm actually running into the same issue. If I want a one to one conversation... User A and User B. User A wants to message User B. So he can join an "A-B" group. But User B has no idea he should also join that group to receive the message (because he's just sitting idle, not knowing someone is trying to message him). How can User B's reply_channel get added?

I thought about having a "Global" group or something everyone is also in, and checking if User B is in that group, and when the "A-B" group is created, pluck User B's reply_channel out of the "Global" group to join "A-B", but that doesn't seem possible...

@andrewgodwin
Copy link
Member

In this sort of situation I'd recommend more of an inbox model - there's just a single "incoming" group per user, and then all messages to them from all users/rooms go into that group; the client side can look at them and display them in different UI sections. That allows you to then easily send private messages from A to B by just dropping messages in B's group labelled as "from: user A".

@oesah
Copy link

oesah commented Jul 29, 2017

Hey, so I am thinking about using it for two projects of my clients.

I need to create something like a messaging framework a la Facebook. So User can communicate with each other, in groups, etc. From @andrewgodwin s solution, I take that it would be possible to use Django Channels as a messaging Framework, am I correct?

So, if someone sends them a message,

  • the user should be notified in real time,
  • the user needs to have an inbox with all messages,
  • the user needs to accept a message from an unknown user,
  • the user needs to reply to a message.

Can Django Channels cover those user cases? What about performancen, if you have a group for 10.000 or more users?

I hope someone can give me some feedback!

@proofit404
Copy link
Member

Hi,

Django Channels is a good choice for applications of this kind. But if you need persistent history you need to do it yourself. Django Channels is just a messaging platform.

All channel layers have reasonable performance in sense of latency. To achieve necessary throughput you need to do performance testing for your exact situation and assemble your own configuration.

Feel free to ask questions in django users mailing list if you have more questions.

@oesah
Copy link

oesah commented Aug 26, 2017

@proofit404

Cool, thanks. I am currently developing with it and it feels good :) Thanks for you efforts, I hope I can contribute soon.

Would it possible to include a tutorial for the use case of one to one communication to the docs? I can also help you with that. That would be a nice feature another important unique selling point of this lib. Let me know, what you think.

At the moment, I am trying to figure out how to establish a nice one to one communication app. I already got it working, but need to refactor and think it through. Maybe I can post is then, once I am done for your opinion. Would appreciate it a lot!

@andrewgodwin
Copy link
Member

I'm definitely going to revamp the tutorials and examples soon as we get close to 2.0, and I should be able to focus on one-to-one communication more in that process. In general, though, you want to store messages in a database or similar and use Channels for notification, rather than as the sole data storage mechanism.

@sebastian-code
Copy link

I apologize for intruding this late in the thread, but I wanted to ask you @oesah how it went for you with the one-on-one communications went, I have trying to figure it out, but I think I can use some orientation if you worked out something.

@anekix
Copy link

anekix commented Aug 28, 2018

@andrewgodwin even i am also looking for a one to one private messaging sort of tutorial.if that can be included in the official tutorial that would be awesome.

@boiyelove
Copy link

@oesah It looks like i also showed up late to the party, still i'd like to know how the user-user chat project went? I'd appreciate some feedback please

@vijayande
Copy link

vijayande commented Feb 21, 2019

can someone please point me in the right direction, how different users can connect to a "WebSocket" to start a long running job and once the job finishes off the users should be notified with the status of their respective jobs. Do I need to use "channel layers" and "channels_redis" to achieve this. Please share any online doc. I am using "Channels 2.1.7" and "Django 2.1.7"

@Znydee
Copy link

Znydee commented Aug 22, 2022

Hi guys, i am also here trying to figure out how to use channels for one to one communication. It looks like there is no tutorial on it on the internet...lol...please, could someone put me through

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants