Skip to content
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

「虎牙消息解码」🙋【 问题交流】解析后的数据存在乱码 #169

Closed
727729853 opened this issue Dec 3, 2024 · 4 comments
Labels
question Further information is requested

Comments

@727729853
Copy link

727729853 commented Dec 3, 2024

		@Override
		public void onOtherCmdMsg(HuyaCmdEnum cmd, ICmdMsg<HuyaCmdEnum> cmdMsg) {
			if (Objects.requireNonNull(cmd) == HuyaCmdEnum.GuardianPresenterInfoNotice) {
				logger.info("监听到守护");
				byte[] dataBytes = new byte[0];
				if (cmdMsg instanceof WSPushMessage) {
					WSPushMessage wsPushMessage = (WSPushMessage) cmdMsg;
					dataBytes = wsPushMessage.getDataBytes();
				} else if (cmdMsg instanceof WSMsgItem) {
					WSMsgItem wsMsgItem = (WSMsgItem) cmdMsg;
					dataBytes = wsMsgItem.getSMsg();
				}
				String body = new String(dataBytes, StandardCharsets.UTF_8);
				logger.info("解析后的内容:{}", body);
				
			}
		}

解析后的内容存在乱码,例如:解析后的内容:� ��K�}���童锦程【798】 �3 �)�>3�F�summer`�|���ahttps://huyaimg.msstatic.com/avatar/1061/66/1b4c1b90aeabdc333212ef43f85007_180_135.jpg?1584006479��u��ahttps://huyaimg.msstatic.com/avatar/1073/f7/5d111b33a50f1d18c09d854a4436ff_180_135.jpg?1649483573�gMـ�gv������� 初爱守护���

具体原因是什么?存在二进制数据还是html?

@727729853 727729853 added the question Further information is requested label Dec 3, 2024
@1962247851
Copy link
Contributor

因为虎牙的消息格式是TARS,https://tarscloud.org
image

@1962247851
Copy link
Contributor

消息字段可以从这里得到,然后继承BaseHuyaMsg写一个消息类,参考HuyaCodecUtil中的解码方法读取消息字段,image

@1962247851 1962247851 pinned this issue Dec 4, 2024
@1962247851 1962247851 changed the title 🙋【 问题交流】解析后的数据存在乱码 「虎牙消息解码」🙋【 问题交流】解析后的数据存在乱码 Dec 4, 2024
@727729853
Copy link
Author

太强了,感谢大佬。一点点心意表示支持!
fe049a4fd60c0ae4edae4f1a82a310a7

@1962247851
Copy link
Contributor

太强了,感谢大佬。一点点心意表示支持! fe049a4fd60c0ae4edae4f1a82a310a7

老板大气,感谢老板的支持

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants