Skip to content

Commit

Permalink
添加鸿蒙推送回调地址
Browse files Browse the repository at this point in the history
  • Loading branch information
heavyrian2012 committed Sep 18, 2024
1 parent 41f62c6 commit f1298a5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions broker/config/wildfirechat.conf
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,10 @@ push.android.server.address http://localhost:8085/android/push
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
push.ios.server.address http://localhost:8085/ios/push

##鸿蒙推送服务器地址,如果不配置会使用android的地址。
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
push.harmony.server.address http://localhost:8085/harmony/push

#*********************************************************************
# 监控配置
#*********************************************************************
Expand Down
10 changes: 8 additions & 2 deletions broker/src/main/java/cn/wildfirechat/push/PushServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static io.moquette.BrokerConstants.PUSH_ANDROID_SERVER_ADDRESS;
import static io.moquette.BrokerConstants.PUSH_IOS_SERVER_ADDRESS;
import static io.moquette.BrokerConstants.*;
import static win.liyufan.im.HttpUtils.HttpPostType.POST_TYPE_Push;

public class PushServer {
Expand All @@ -47,6 +46,7 @@ public interface PushMessageType {

private String androidPushServerUrl;
private String iOSPushServerUrl;
private String harmonyPushServerUrl;

private PushServer() {
}
Expand All @@ -59,6 +59,10 @@ public void init(IConfig config, ISessionsStore sessionsStore) {
this.sessionsStore = sessionsStore;
this.androidPushServerUrl = config.getProperty(PUSH_ANDROID_SERVER_ADDRESS);
this.iOSPushServerUrl = config.getProperty(PUSH_IOS_SERVER_ADDRESS);
this.harmonyPushServerUrl = config.getProperty(PUSH_HARMONY_SERVER_ADDRESS);
if(StringUtil.isNullOrEmpty(harmonyPushServerUrl)) {
harmonyPushServerUrl = androidPushServerUrl;
}
}

public void pushMessage(PushMessage pushMessage, String deviceId, String pushContent) {
Expand Down Expand Up @@ -106,6 +110,8 @@ private void pushMessageInternel(PushMessage pushMessage, String deviceId, Strin
if (session.getPlatform() == ProtoConstants.Platform.Platform_iOS || session.getPlatform() == ProtoConstants.Platform.Platform_iPad) {
url = iOSPushServerUrl;
pushMessage.voipDeviceToken = session.getVoipDeviceToken();
} else if (session.getPlatform() == ProtoConstants.Platform.Platform_Harmony || session.getPlatform() == ProtoConstants.Platform.Platform_HarmonyPad) {
url = harmonyPushServerUrl;
}
HttpUtils.httpJsonPost(url, gson.toJson(pushMessage, pushMessage.getClass()), POST_TYPE_Push);
} else {
Expand Down
1 change: 1 addition & 0 deletions broker/src/main/java/io/moquette/BrokerConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public final class BrokerConstants {

public static final String PUSH_ANDROID_SERVER_ADDRESS = "push.android.server.address";
public static final String PUSH_IOS_SERVER_ADDRESS = "push.ios.server.address";
public static final String PUSH_HARMONY_SERVER_ADDRESS = "push.harmony.server.address";

public static final String MONITOR_Exception_Event_Address = "monitor.exception_event_address";

Expand Down
4 changes: 4 additions & 0 deletions distribution/src/main/resources/wildfirechat.conf
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ push.android.server.address http://localhost:8085/android/push
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
push.ios.server.address http://localhost:8085/ios/push

##鸿蒙推送服务器地址,如果不配置会使用android的地址。
##注意回调是单线程回调,接收服务必须在同一内网,且异步处理快速返回,否则会有延迟问题!!
push.harmony.server.address http://localhost:8085/harmony/push

#*********************************************************************
# 监控配置
#*********************************************************************
Expand Down

0 comments on commit f1298a5

Please sign in to comment.