25 changed files with 387 additions and 130 deletions
@ -0,0 +1,40 @@ |
|||
|
|||
// 是否普通消息
|
|||
let isNormal = function(type){ |
|||
return type>=0 && type < 10; |
|||
} |
|||
|
|||
// 是否状态消息
|
|||
let isStatus = function(type){ |
|||
return type>=10 && type < 20; |
|||
} |
|||
|
|||
// 是否提示消息
|
|||
let isTip = function(type){ |
|||
return type>=20 && type < 30; |
|||
} |
|||
|
|||
// 操作交互类消息
|
|||
let isAction = function(type){ |
|||
return type>=40 && type < 50; |
|||
} |
|||
|
|||
// 单人通话信令
|
|||
let isRtcPrivate = function(type){ |
|||
return type>=100 && type < 300; |
|||
} |
|||
|
|||
// 多人通话信令
|
|||
let isRtcGroup = function(type){ |
|||
return type>=200 && type < 400; |
|||
} |
|||
|
|||
|
|||
export { |
|||
isNormal, |
|||
isStatus, |
|||
isTip, |
|||
isAction, |
|||
isRtcPrivate, |
|||
isRtcGroup |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
import http from './httpRequest.js' |
|||
|
|||
class RtcPrivateApi { |
|||
} |
|||
|
|||
RtcPrivateApi.prototype.call = function(uid, mode, offer) { |
|||
return http({ |
|||
url: `/webrtc/private/call?uid=${uid}&mode=${mode}`, |
|||
method: 'post', |
|||
data: JSON.stringify(offer) |
|||
}) |
|||
} |
|||
|
|||
RtcPrivateApi.prototype.accept = function(uid, answer) { |
|||
return http({ |
|||
url: `/webrtc/private/accept?uid=${uid}`, |
|||
method: 'post', |
|||
data: JSON.stringify(answer) |
|||
}) |
|||
} |
|||
|
|||
|
|||
RtcPrivateApi.prototype.handup = function(uid) { |
|||
return http({ |
|||
url: `/webrtc/private/handup?uid=${uid}`, |
|||
method: 'post' |
|||
}) |
|||
} |
|||
|
|||
RtcPrivateApi.prototype.cancel = function(uid) { |
|||
return http({ |
|||
url: `/webrtc/private/cancel?uid=${uid}`, |
|||
method: 'post' |
|||
}) |
|||
} |
|||
|
|||
RtcPrivateApi.prototype.reject = function(uid) { |
|||
return http({ |
|||
url: `/webrtc/private/reject?uid=${uid}`, |
|||
method: 'post' |
|||
}) |
|||
} |
|||
|
|||
RtcPrivateApi.prototype.failed = function(uid, reason) { |
|||
return http({ |
|||
url: `/webrtc/private/failed?uid=${uid}&reason=${reason}`, |
|||
method: 'post' |
|||
}) |
|||
} |
|||
|
|||
RtcPrivateApi.prototype.sendCandidate = function(uid, candidate) { |
|||
return http({ |
|||
url: `/webrtc/private/candidate?uid=${uid}`, |
|||
method: 'post', |
|||
data: JSON.stringify(candidate) |
|||
}); |
|||
} |
|||
|
|||
RtcPrivateApi.prototype.heartbeat = function(uid) { |
|||
return http({ |
|||
url: `/webrtc/private/heartbeat?uid=${uid}`, |
|||
method: 'post' |
|||
}) |
|||
} |
|||
|
|||
export default RtcPrivateApi; |
|||
@ -0,0 +1,40 @@ |
|||
|
|||
// 是否普通消息
|
|||
let isNormal = function(type){ |
|||
return type>=0 && type < 10; |
|||
} |
|||
|
|||
// 是否状态消息
|
|||
let isStatus = function(type){ |
|||
return type>=10 && type < 20; |
|||
} |
|||
|
|||
// 是否提示消息
|
|||
let isTip = function(type){ |
|||
return type>=20 && type < 30; |
|||
} |
|||
|
|||
// 操作交互类消息
|
|||
let isAction = function(type){ |
|||
return type>=40 && type < 50; |
|||
} |
|||
|
|||
// 单人通话信令
|
|||
let isRtcPrivate = function(type){ |
|||
return type>=100 && type < 300; |
|||
} |
|||
|
|||
// 多人通话信令
|
|||
let isRtcGroup = function(type){ |
|||
return type>=200 && type < 400; |
|||
} |
|||
|
|||
|
|||
export { |
|||
isNormal, |
|||
isStatus, |
|||
isTip, |
|||
isAction, |
|||
isRtcPrivate, |
|||
isRtcGroup |
|||
} |
|||
Loading…
Reference in new issue