Forums Register Login

Communication between applet instances

+Pie Number of slices to send: Send
Hi,

I was wondering, is there way for to separate applet instances (created from the same page but on different computers) to communicate with each other? I want to create a live message system (not going through a database) where a player can send a message to another player currently playing the same game.

I thought of having the messages stored in a db and having the applet refresh every 2 seconds to retrieve any newly stored messages but this seems too bandwidth-consuming. Am I wrong?

Thank you
+Pie Number of slices to send: Send
 

not going through a database


I thought of having the messages stored in a db


OK, so I see some conflicting requirements here :-)

You'll need some active server-side component, like a servlet. That would send and receive messages from/to each user, and store them (possibly in memory) in between. Wouldn't have to be a servlet, though - any language would be fine, although I'd probably go for HTTP as the protocol. And it would need to run on the same server where the applets are served from, or you'll need to work around security restrictions.

I don't necessarily see a bandwidth problem caused by checking every 2 seconds (assuming we're not talking about hundreds of clients) - request and response would be quite short unless there was actual data to be transported. It may not make sense because of the network latency, though, or because people simply don't send messages that often and that quickly.
+Pie Number of slices to send: Send
yeah my initial thought was going through a db, and i was looking for something not going through a db.

given that i am not really familiar with servlets and short on time, do you think that storing the messages in a db and performing queries every 1-2 secs is a good idea? the game will not be playing by hundreds i assure you ;p it is for a uni project.
+Pie Number of slices to send: Send
For a school project it's fine, but in general, using JDBC in applets is not a good idea for security reasons. And most decidedly so if the applet is accessible from outside of the firewall.

The DB needs to be on the same machine as the web server, or you'll run into the applet sandbox restrictions.
+Pie Number of slices to send: Send
im not connecting directly via jdbc, im using PHP as an intermediate tier
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1089 times.
Similar Threads
Datagram lost in network
Very basic instance addressing question
Polymorphic method invocations apply only to overridden instance methods.
Where is the Plugin Console?
OO design question?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:53:13.