Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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/

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.