Hello!
I am writing simple client-server network game using RMI.
Client side has three classes:
- view: simple GUI
- model: engine, which invokes methods on server
- controller: connecting view with model
Client-server communication uses callback, so server
can invoke methods on client.
When server invokes model method it modify its
fields values. Controller and view don't know that
fields values has been changed.
My question is:
How to immediately notify controller or view about invoking
remote method on model? How to do it in MVC?
Is this possible to bind model's fields with view items?
Is there more suitable design pattern for such an application?
Thanks in advance,
Piotr Piwko
Oliver Wong - 15 Dec 2006 21:08 GMT
> When server invokes model method it modify its
> fields values. Controller and view don't know that
[quoted text clipped - 5 lines]
> Is this possible to bind model's fields with view items?
> Is there more suitable design pattern for such an application?
MVC is usually coupled with the Observer pattern, where the View is an
observer of the Model. I'm not sure why the controller would need to be
notified of changes in the Model, but if this is a requirement, then I
supposed you could make the Controller an observer of the model too.
- Oliver
oblivion - 15 Dec 2006 21:37 GMT
Oliver Wong napisal(a):
> MVC is usually coupled with the Observer pattern, where the View is an
> observer of the Model. I'm not sure why the controller would need to be
> notified of changes in the Model, but if this is a requirement, then I
> supposed you could make the Controller an observer of the model too.
>
> - Oliver
Thanks, I didn't know about Observer pattern. I'll get it a try ,I
think it's the solution :)
Oliver Wong - 15 Dec 2006 21:10 GMT
> I am writing simple client-server network game using RMI.
> Client side has three classes:
> - view: simple GUI
> - model: engine, which invokes methods on server
> - controller: connecting view with model
I forgot to mention, unless the Model is located on one computer, and
the Views and Controllers are located on a different one, then the fact that
you're using RMI isn't very relevant to your problem.
- Oliver