I'm working in a java project with Socket, MVC Pattern and Observer/Observable Pattern. I have to do a double notify from a Controller to a view like follow:
this.game.notifyObservers(new InfoMessageType(InfoMessageTypeEnum.SHOWINITIALMMESSAGE, this.game));
this.game.notifyObservers(new InfoMessageType(InfoMessageTypeEnum.SHOWGAMEBOARD, this.game));
The problem is that the first notifyObservers works well, but the seconds look like it doesn't works. I tried to comment the first notifyObserver and the second now works fine. it seems like is not possible to do a multiple notifyObserver.
For istance: the first notifyObserver contain the String "Game Ready" the second notifyObserver contain the String "GameBoard Status: "
The Output is just: "Game Ready"
And if I comment the first notifyObserver the output is "GameBoard Status: "
I don't have any java runtime error, just don't print what I want.
How can I resolve it?
EDIT: before notifyObservers calls I add the observers like follow
for(ServerSocketView serverSocketView : serverSocketViews)
this.game.addObserver(serverSocketView);
And i never remove the observers from the game and from the methods that i call