1

I am writing a small desktop application which is about showing notifications to the client who is using this application.so my application should get notifications from a server where all the notifications are stored.so if there are 100 clients using this app and if I add some notifications to server how can I send these data to 100 clients...please give me some idea what APIs or which technology I can use to get this functionality implemented.this application is a desktop application

Prajyod Kumar
  • 395
  • 2
  • 4
  • 15

3 Answers3

0

There are some possibilities:
1. Via Sockets, ServerSocket/Socket/Multicast
Push-Notification: Open a listening socket on every client and open a connection from server to send a notification from server to client.
Pull-Notification: Open a listening socket on the server and open e.g. every 10 seconds or so a connection from the clients to the server to look for new notifications on the server.
Multicast: Send the same message to multiple clients with one API call.
2. JDBC/JPA: Transfer messages over the database, if you have one.
3. JMS: Use a message topic
...

The best method depends on your needs.

pcejrowski
  • 603
  • 5
  • 15
Gren
  • 1,850
  • 1
  • 11
  • 16
0

Its simple ...

1) Make Arraylist of socket that has socket of all clients. // i.e when new client connected then add its socket into th ArrayList.
2) When ever there is any update just iterate through the ArralyList and send notification to all the connected clients.
Junaid
  • 2,572
  • 6
  • 41
  • 77
0

There are two (maybe more but I know those two. :) ) patterns to deal with those types of scenarios. Observer and publish-subscriber

They are very similar with the difference that for the Observer pattern, the "standard" implementation might create memory leaks while in a publish-subscriber scenario, neither the publish or subscriber knows about each other.

Have a look a the links below that might give you a better idea.

http://en.wikipedia.org/wiki/Observer_pattern http://www.oodesign.com/observer-pattern.html

http://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern http://www.eaipatterns.com/PublishSubscribeChannel.html

Desorder
  • 1,549
  • 12
  • 16