-
Notifications
You must be signed in to change notification settings - Fork 461
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
can this server push message to client ? #4
Comments
Hi,
I am not sure if this design has that ability already, but I have made a
more advanced version of a TCP server which can do that -
based on exactly the same design. It is definitely possible to add.
The extended design assigns a socket ID to each socket, and inserts them
into a Map. Then each socket can be identified via that
id (just an incrementing long). Also, the messages that are read from a
socket contains a reference to the socket (or socket ID)
of the socket they came from, so a reply can be sent back to the correct
socket.
- Jakob Jenkov
…On Sun, Jul 23, 2017 at 11:53 AM, mmmmar ***@***.***> wrote:
I want to make a Tcp Server that can push message to client, and I'm worry
about how to save and mark every SocketChannel of client.
does your code have this function ? thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADb7WaTagmqWiBloOJC7mEHCc1dBowy2ks5sQxgTgaJpZM4OgaMr>
.
--
Jakob Jenkov
[email protected]
Founder, CEO
Jenkov Aps
http://jenkov.com
http://tutorials.jenkov.com
http://feeds2.feedburner.com/jenkov-com
|
@jjenkov yeah. I have the same idea. I think it may be difficult to remove socket from the map when the socket disconnects with server, so the heartbeat may be need to detect that. |
Actually, this server already assigns an ID to the sockets and puts them into a Map. It also removes them again when the sockets are closed. Look at this code from the SocketProcessor:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to make a Tcp Server that can push message to client, and I'm worry about how to save and mark every SocketChannel of client.
does your code have this function ? thanks.
The text was updated successfully, but these errors were encountered: