diff --git a/clients/java/wechat-ferry-mvn/pom.xml b/clients/java/wechat-ferry-mvn/pom.xml
index 3d5514e..084258a 100644
--- a/clients/java/wechat-ferry-mvn/pom.xml
+++ b/clients/java/wechat-ferry-mvn/pom.xml
@@ -59,6 +59,12 @@
dom4j
2.1.3
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.13
+
com.google.protobuf
diff --git a/clients/java/wechat-ferry-mvn/src/main/java/com/wechat/ferry/config/WeChatConfiguration.java b/clients/java/wechat-ferry-mvn/src/main/java/com/wechat/ferry/config/WeChatConfiguration.java
index a364a76..21080e5 100644
--- a/clients/java/wechat-ferry-mvn/src/main/java/com/wechat/ferry/config/WeChatConfiguration.java
+++ b/clients/java/wechat-ferry-mvn/src/main/java/com/wechat/ferry/config/WeChatConfiguration.java
@@ -2,6 +2,7 @@ package com.wechat.ferry.config;
import javax.annotation.Resource;
+import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -22,6 +23,9 @@ public class WeChatConfiguration {
@Resource
private WeChatFerryProperties properties;
+ @Resource
+ private ServerProperties serverProperties;
+
@Bean
public WeChatSocketClient client() {
log.debug("[读取配置文件]-端口:{},地址:{}", properties.getSocketPort(), properties.getDllPath());
@@ -29,8 +33,6 @@ public class WeChatConfiguration {
// Client client = new Client("127.0.0.1", 10086);
// 本地启动 RPC
- // Client client = new Client(); // 默认 10086 端口
- // Client client = new Client(10088,true); // 也可以指定端口
WeChatSocketClient wechatSocketClient = new WeChatSocketClient(properties.getSocketPort(), properties.getDllPath());
// 是否已登录
@@ -69,12 +71,17 @@ public class WeChatConfiguration {
// 发送表情消息,gif 必须要存在
// client.sendEmotion("C:\\Projs\\WeChatFerry\\emo.gif", "filehelper");
+ // 使用本机打印
+ String url = "http://localhost:" + serverProperties.getPort() + "/wechat/msg/receive";
// 接收消息,并调用 printWxMsg 处理
wechatSocketClient.enableRecvMsg(100);
Thread thread = new Thread(new Runnable() {
public void run() {
while (wechatSocketClient.getIsReceivingMsg()) {
- wechatSocketClient.printWxMsg(wechatSocketClient.getMsg());
+ // 只打印
+ // wechatSocketClient.printWxMsg(wechatSocketClient.getMsg());
+ // 转发到boot项目进行消息处理
+ wechatSocketClient.forwardMsg(wechatSocketClient.getMsg(), url);
}
}
});
diff --git a/clients/java/wechat-ferry-mvn/src/main/java/com/wechat/ferry/controller/WeChatMsgController.java b/clients/java/wechat-ferry-mvn/src/main/java/com/wechat/ferry/controller/WeChatMsgController.java
new file mode 100644
index 0000000..d7d9f95
--- /dev/null
+++ b/clients/java/wechat-ferry-mvn/src/main/java/com/wechat/ferry/controller/WeChatMsgController.java
@@ -0,0 +1,44 @@
+package com.wechat.ferry.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.wechat.ferry.entity.TResponse;
+import com.wechat.ferry.enums.ResponseCodeEnum;
+import com.wechat.ferry.service.WeChatMsgService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 控制层-微信消息处理
+ *
+ * @author chandler
+ * @date 2024-10-01 14:25
+ */
+@Slf4j
+@RestController
+@RequestMapping("/wechat/msg")
+@Api(tags = "微信消息处理-接口")
+public class WeChatMsgController {
+
+ private WeChatMsgService weChatMsgService;
+
+ @Autowired
+ public void setWeChatMsgService(WeChatMsgService weChatMsgService) {
+ this.weChatMsgService = weChatMsgService;
+ }
+
+ @ApiOperation(value = "接收微信消息", notes = "receiveMsg")
+ @PostMapping(value = "/receive")
+ public TResponse