Jump to content

SimpleNetworkWrapper return packet problem


octarine-noise

Recommended Posts

I'd like to use the SimpleNetworkWrapper in a setup where the client sends a Request packet to the server, and the server answers with a Reply packet. I have the wrapper set up to a channel, and an appropriate Handler<Request, Reply> registered to a discriminator value. However, when I return new Reply(); from the handler, things start getting seriously weird.

 

In SSP, things kind of work all right. If I open the game to LAN, and connect with a second client, all reply packets will go to the second client, wherever they originated from. If a third client joins, all reply packets go to the third, etc. If I then disconnect with the last logged in client, the one that got all the reply packets, their target doesn't revert back to the second-last, but the packets will instead disappear into the void.

If I log ctx.getServerHandler().netManager.channel().toString() however, it looks all right, with the correct socket endpoints depending on the source of the request packet. They just get turned around somehow.

 

With a dedicated server, even one client will have problems. The reply packets sometimes arrive, sometimes not. I did not observe any pattern to it, but I didn't look too long either (I was getting royally frustrated by this point).

 

I took a look at the SimpleChannelHandlerWrapper class, and it was suspiciously devoid of any mention of FMLOutboundHandler.OutboundTarget.REPLY, which is surprising, since FMLEventChannel uses it when routing reply packets from the packet event.

 

I tried this just before returning the reply packet:

 

ctx.getServerHandler().netManager.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.REPLY);

 

It didn't work out so well, it set up an infinite loop.

 

Then I sidestepped the whole issue by doing the following:

 

simpleNetworkWrapperInstance.sendTo(new Reply(), ctx.getServerHandler().playerEntity);
return null;

 

Now everything is perfect, works as intended.

 

Did I miss a setting somewhere, or is SimpleNetworkWrapper borked?

 

Using Forge 10.12.1.1098.

Link to comment
Share on other sites

That does seem like the reply mechanism is "borked".  As you did do, you can of course create your own reply message easily enough, but it is a shame if the standard mechanism isn't working. 

 

If none of the experts here can point out an obvious flaw in your approach you should probably submit a bug report.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.