Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Inter Application Form Communication Observer Pattern

Observer pattern? Where do i get examples of this in Java (i know google but was hoping for some personal insight also.)

On to a proper explanation of my issue:

i have 3 forms/windows. "board" is the main form that loads as the application.

"chat" is where the text chat takes place.

"network" is where network connection is established.

i have the game (connect4) working locally and i would like to implement a networked version of it also.

my idea is maybe it is related to Observer pattern to have a thread (or something) monitoring network state during runtime and update the chat and board forms of the current network status as well as delivering received data from the network.

are my ideas valid? or how should i go about establishing network and network status updates throughout the application?

thank you for your input.

board http://img39.imageshack.us/img39/5221/boardz.jpg

chat http://img691.imageshack.us/img691/3629/chatos.jpg

network http://img441.imageshack.us/img441/5906/networks.jpg

EDIT: is there a book on Java Observer pattern any one can recommend?

like image 531
iTEgg Avatar asked Feb 03 '26 09:02

iTEgg


1 Answers

The observer pattern is often referred to as event listeners in Java. You might want to search for that as well.

Your idea seems valid, although you will need to delve in more technical details at some point. Are you implementing your network communication using RMI, Caucho, HTTPInvoker?

Anyhow you need the game "server" to be able to publish updates to all players. This can be implemented using polling or by passing an object over the network.

There are some good references right here on StackOverflow - check this one and that one also. That should get you going.

like image 142
Etienne Avatar answered Feb 04 '26 22:02

Etienne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!