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

Please Help!!!!

public static void encode(MessageFromClient msg, FriendlyByteBuf buf) {
//        buf.writeString(msg.message);
        LOGGER.info("here:"+msg.message);
        buf.writeUtf(msg.message);
//        try {
//            buf.writeBytes(msg.message.getBytes("utf-8"));
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//        }
    }

I use this method to send string data to the server,this is correct for client side printing

{"id":"Manager","formPlug":"Manager","toPlug":"Trmenu","type":3,"playerName":"mohuangNPC","uuid":"85bfd415-4262-352e-ab70-e0f08c077db1","msg":"trmenu open Main"}

But what the server receives is:

SOH{"id":"Manager","formPlug":"Manager","toPlug":"Trmenu","type":3,"playerName":"mohuangNPC","uuid":"85bfd415-4262-352e-ab70-e0f08c077db1","msg":"trmenu open Main"

The prefix is SOH,I searched for information and found that it belongs to ascii,and the symbol is missing at the end "}"

This is the server receiving code:

 public void onPluginMessageReceived(String channel, Player player, byte[] message) {
        ByteArrayDataInput in = ByteStreams.newDataInput(message);
        String subchannel = in.readUTF();
        Logger.debug(subchannel);
        String[] split = subchannel.split("\001", -1);
        if(split.length == 2){
            subchannel = split[1];
        }else{
            subchannel = split[0];
        }
        String[] split1 = subchannel.split("\u0001", -1);
        if(split1.length == 2){
            subchannel = split1[1];
        }else{
            subchannel = split1[0];
        }
        Logger.debug(subchannel);
        subchannel = subchannel + "}";
        Logger.debug(subchannel);
}

I now manually remove the prefix and add the suffix,but I want to know what is the reason for this!

If anyone knows please help me, I would be very grateful.

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.