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 send messages to specific clients? #5

Closed
refactor2 opened this Issue Aug 28, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@refactor2

refactor2 commented Aug 28, 2017

how can i sent messages to some clients not all connected clients?

@refactor2 refactor2 changed the title from how can i set messages to some clients not all connected clients? to how can i sent messages to some clients not all connected clients? Aug 28, 2017

@tpeczek tpeczek added the Question label Aug 28, 2017

@tpeczek

This comment has been minimized.

Show comment
Hide comment
@tpeczek

tpeczek Aug 28, 2017

Owner

The IServerSentEventsService exposes GetClients() method which will return list of currently connected clients. Every client (represented by IServerSentEventsClient) exposes User property and SendEventAsync method.

Owner

tpeczek commented Aug 28, 2017

The IServerSentEventsService exposes GetClients() method which will return list of currently connected clients. Every client (represented by IServerSentEventsClient) exposes User property and SendEventAsync method.

@tpeczek tpeczek changed the title from how can i sent messages to some clients not all connected clients? to How to send messages to specific clients? Aug 28, 2017

@refactor2

This comment has been minimized.

Show comment
Hide comment
@refactor2

refactor2 Aug 29, 2017

if use nginx to load balance, the messages will not sent all clients?
private readonly ConcurrentDictionary<Guid, ServerSentEventsClient> _clients = new ConcurrentDictionary<Guid, ServerSentEventsClient>();

refactor2 commented Aug 29, 2017

if use nginx to load balance, the messages will not sent all clients?
private readonly ConcurrentDictionary<Guid, ServerSentEventsClient> _clients = new ConcurrentDictionary<Guid, ServerSentEventsClient>();

@tpeczek

This comment has been minimized.

Show comment
Hide comment
@tpeczek

tpeczek Aug 29, 2017

Owner

The core aspect of Server Sent Events is persistent connection. In load balancing scenario this connection is being made to a specific instance behind the load balancer and only this instance can send messages to client represented by that connection. If you want to send an update generated in specific instance to clients connected to all instances you need a way for communicating that update across all the instances (one option can be Pub/Sub functionality provided by Redis, but there are others).

Owner

tpeczek commented Aug 29, 2017

The core aspect of Server Sent Events is persistent connection. In load balancing scenario this connection is being made to a specific instance behind the load balancer and only this instance can send messages to client represented by that connection. If you want to send an update generated in specific instance to clients connected to all instances you need a way for communicating that update across all the instances (one option can be Pub/Sub functionality provided by Redis, but there are others).

@refactor2

This comment has been minimized.

Show comment
Hide comment
@refactor2

refactor2 Aug 30, 2017

Thanks you very mush
Can I send messages into Redis publish channels,then use IServerSentEventsService subscribe the channels,and then use SendEventAsync method send to all connected clients in the load balancing instances?

refactor2 commented Aug 30, 2017

Thanks you very mush
Can I send messages into Redis publish channels,then use IServerSentEventsService subscribe the channels,and then use SendEventAsync method send to all connected clients in the load balancing instances?

@tpeczek

This comment has been minimized.

Show comment
Hide comment
@tpeczek

tpeczek Aug 30, 2017

Owner

Yes, that is the general idea.

Owner

tpeczek commented Aug 30, 2017

Yes, that is the general idea.

@refactor2

This comment has been minimized.

Show comment
Hide comment
@refactor2

refactor2 commented Aug 31, 2017

ok,thanks

@refactor2 refactor2 closed this Aug 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment