Blame view

app/src/main/java/com/huaheng/mobilewms/websocket/WebsocketConstants.java 1.54 KB
1
2
package com.huaheng.mobilewms.websocket;
周峰 authored
3
4
5
import com.huaheng.mobilewms.bean.Constant;
import com.huaheng.mobilewms.util.WMSUtils;
6
7
8
9
10
11
12
13
14
15
16
public class WebsocketConstants {

    //客户端发送心跳的最小间隔
    public final static int HEART_BEAT_CLIENT = 50000;
    //期望服务端发送心跳的间隔
    public final static int HEART_BEAT_SERVER = 50000;
    //上行消息地址
    public final static String UP_STRING_MESSAGE_DEST = "/app/websocket/message/string";
    public final static String UP_JSON_MESSAGE_DEST = "/app/websocket/message/json";
    public final static String UP_CONFIRM_MESSAGE_DEST = "/app/websocket/message/confirm";
周峰 authored
17
18
    //建立websocket握手的http地址后缀
    public final static String URI_SUFFIX = "endpoint/websocket";
19
20
21
22
23
24
25
26

    //订阅广播消息话题地址
    public final static String SUBSCRIBE_TOPIC_MESSAGE = "/topic/message";
    //订阅用户消息话题地址
    public final static String SUBSCRIBE_USER_TOPIC_MESSAGE = "/user/topic/message";

    public final static String HEADER_MEG_ID = "msg-id";
周峰 authored
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    public static String getUri(){
        String httpNet = WMSUtils.getData(Constant.NETWORK);
        String uri = "";
//                .replaceFirst("http","ws");
        if(httpNet.startsWith("http")){
            uri = httpNet.replaceFirst("http", "ws");
        }
        if(httpNet.startsWith("https")){
            uri = httpNet.replaceFirst("https", "wss");
        }
        if(uri.endsWith("/")){
            return uri + URI_SUFFIX;
        }else{
            return uri + "/" + URI_SUFFIX;
        }
    }
43
}