由于项目传输的是视频和音频所以使用SIP协议,数据格式使用的是JSON,所以下面分析的主要是以SIP,JSON为主.
sip2peer支持:udp,tcp,tls,sctp
BaseMessage.java
public static final String PROTO_UDP = "udp";
public static final String PROTO_TCP = "tcp";
public static final String PROTO_TLS = "tls";
public static final String PROTO_SCTP = "sctp";
sip2peer对消息处理进行了封装,下面通过源码分析下:
她的消息类型分为:MESSAGE,REFER,NOTIFY,SUBSCRIBE,PUBLISH等,现在主要看下:MESSAGE
下面是请求服务的消息:它是封装后的sip消息,可以通过抓包工具获取.
MESSAGE sip:10.84.77.75:6066 SIP/2.0
Via: SIP/2.0/UDP 10.84.77.72:5075;rport;branch=z9hG4bK17399a3b
Max-Forwards: 70
To: <sip:10.84.77.75:6066>
From: <sip:kate@10.84.77.72:5075>;tag=639102045520
Call-ID: 348930525975@10.84.77.72
CSeq: 1 MESSAGE
Expires: 3600
User-Agent: mjsip 1.7
Content-Length: 8
Content-Type: application/text
TEST_NAT
通过代码分析上面数据:
客户端组装消息,发送过程:
Peer.java
/**
* To send peer message through <code>toContactAddress</code>
*
* @param toAddress destination address (local)
* @param toContactAddre