-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gameRoom.sendBroadcast(networkEvent) duplicates the message #12
Comments
Could you check for the event type at client side? This could be some other event say "START" sent by server, not the network event. Also instead of sending one network event send same network event say 5 times to see result. I do not see a check in your code to see if the event is actually "NETWORK_EVENT". Finally, any reason why you are not using the jetclient library at client side? That will provide you with a onDataIn just like server side. |
there is check for NETWORK_MESSAGE type
|
Looks like a bug, let me check it out. |
if i can put some debugging code for you, let me know |
I did an initial test case and could not reproduce it. This is what I did
Here is the code for the new room I added. public class BroadcastZombieRoom extends ZombieRoom { public BroadcastZombieRoom(GameRoomSessionBuilder sessionBuilder){ super(sessionBuilder); } @Override public void onLogin(final PlayerSession playerSession) { playerSession.addHandler(new DefaultSessionEventHandler(playerSession) { }); } } Did you by any chance add 2 session event handlers to the |
How I add print number of added handlers by mine? I have tried but it produce null pointer exception. Before adding another handler to the PlayerSession request I do like this |
The default handler which handles any event is added using Events.ANY. So you could also try to do request.getEventDispatcher().removeHandlersForEvent(Events.ANY); |
Overall as beginner of netty and your java server I can say that handlers and eventType mapping is confusing. As you have said before there are internal netty handlers, I think those should be accessed directly. But for handlers programmed and added by programmer there should be more convenient way to manage it. |
Thanks for the feedback! Let me see what can be done, either through document or code wise to have neater control on event handlers. |
I have added a "clear" method, which you can use to remove all event handlers associated with a dispatcher. Binaries not updated. |
At server side I create a new GameRoomSession, add existing session there
NettyMessageBuffer outBuf = new NettyMessageBuffer();
outBuf.writeBytes(outHeader.toByteArray());
NetworkEvent networkEvent = Events.networkEvent(outBuf);
gameRoom.sendBroadcast(networkEvent);
executed at server only once. gameRoom has only 1 session.
At client:
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
ChannelBuffer buffer = (ChannelBuffer) event.getSource();
System.out.println("NETWORK_MESSAGE received!");
appears twice and content is identical.
NETWORK_MESSAGE received!
MESSAGE_TYPE Fri Sep 07 17:29:14 KST 2012
Any idea?
The text was updated successfully, but these errors were encountered: