Skip to content

Commit ffa6a0e

Browse files
committed
rtc添加两个新的物模型_sys_called_id和_sys_caller_id
Change-Id: I8e48f5cf93e3151908b615b811eba1615eb9ef49
1 parent 338bb8f commit ffa6a0e

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed

app/src/main/java/com/tencent/iot/explorer/link/App.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,16 @@ class App : Application(), Application.ActivityLifecycleCallbacks, PayloadMessag
470470

471471
L.d("上报数据:id=$id value=$value")
472472
var userId = SharePreferenceUtil.getString(activity, CONFIG, CommonField.USER_ID)
473-
var data = "{\"$id\":$value, \"${MessageConst.USERID}\":\"$userId\"}"
473+
var callerId = ""
474+
var calledId = ""
475+
if (TRTCUIManager.getInstance().callingDeviceId.equals("")) { //被叫
476+
callerId = deviceId
477+
calledId = userId
478+
} else { //主叫
479+
callerId = userId
480+
calledId = deviceId
481+
}
482+
var data = "{\"$id\":$value, \"${MessageConst.USERID}\":\"$userId\", \"${MessageConst.TRTC_CALLEDID}\":\"$calledId\", \"${MessageConst.TRTC_CALLERID}\":\"$callerId\"}"
474483
HttpRequest.instance.controlDevice(productId, deviceName, data, object: MyCallback {
475484
override fun fail(msg: String?, reqCode: Int) {
476485
if (msg != null) L.e(msg)

app/src/main/java/com/tencent/iot/explorer/link/TRTCAppSessionManager.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,16 @@ class TRTCAppSessionManager : TRTCSessionManager() {
103103

104104
L.d("上报数据:id=$id value=$value")
105105
val userId = SharePreferenceUtil.getString(App.activity, App.CONFIG, CommonField.USER_ID)
106-
var data = "{\"$id\":$value, \"${MessageConst.USERID}\":\"$userId\"}"
106+
var callerId = ""
107+
var calledId = ""
108+
if (TRTCUIManager.getInstance().callingDeviceId.equals("")) { //被叫
109+
callerId = deviceId
110+
calledId = userId
111+
} else { //主叫
112+
callerId = userId
113+
calledId = deviceId
114+
}
115+
var data = "{\"$id\":$value, \"${MessageConst.USERID}\":\"$userId\", \"${MessageConst.TRTC_CALLEDID}\":\"$calledId\", \"${MessageConst.TRTC_CALLERID}\":\"$callerId\"}"
107116
HttpRequest.instance.controlDevice(productId, deviceName, data, object: MyCallback {
108117
override fun fail(msg: String?, reqCode: Int) {
109118
if (msg != null) L.e(msg)

app/src/main/java/com/tencent/iot/explorer/link/mvp/model/ControlPanelModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class ControlPanelModel(view: ControlPanelView) : ParentModel<ControlPanelView>(
178178
TRTCUIManager.getInstance().callingDeviceId = "$productId/$deviceName" //保存下设备id(productId/deviceName)
179179
val userId = SharePreferenceUtil.getString(App.activity, App.CONFIG, CommonField.USER_ID)
180180
val agent = "android/1.4.0 (Android" + Build.VERSION.SDK_INT + ";" + Build.BRAND + " " + Build.MODEL + ";" + Locale.getDefault().language + "-" + Locale.getDefault().country + ")"
181-
data = "{\"$id\":$value, \"$USERID\":\"$userId\", \"${MessageConst.AGENT}\":\"$agent\"}"
181+
data = "{\"$id\":$value, \"$USERID\":\"$userId\", \"${MessageConst.AGENT}\":\"$agent\", \"${MessageConst.TRTC_CALLEDID}\":\"$deviceId\", \"${MessageConst.TRTC_CALLERID}\":\"$userId\"}"
182182

183183
}
184184
}

sdk/explorer-link-android/src/main/java/com/tencent/iot/explorer/link/core/auth/message/MessageConst.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@ object MessageConst {
4646
const val AGENT = "_sys_user_agent"
4747
const val TRTC_EXTRA_INFO = "_sys_extra_info";
4848
const val TRTC_REJECT_USERID = "rejectUserId";
49+
const val TRTC_CALLEDID = "_sys_called_id"
50+
const val TRTC_CALLERID = "_sys_caller_id"
4951

5052
}

sdk/explorer-link-rtc/src/main/java/com/tencent/iot/explorer/link/rtc/consts/Common.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public class Common {
2323

2424
public static final String TRTC_EXTRA_INFO = "_sys_extra_info";
2525

26+
public static final String TRTC_CALLEDID = "_sys_called_id";
27+
28+
public static final String TRTC_CALLERID = "_sys_caller_id";
29+
2630
public static final String TRTC_REJECT_USERID = "rejectUserId";
2731

2832
public static final String TRTC_DEVICE_CHANGE = "DeviceChange";

sdk/explorer-link-rtc/src/main/java/com/tencent/iot/explorer/link/rtc/model/TRTCUIManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ public void payloadMessage(TRTCPayload trtcPayload, String userId, TRTCCallback
117117
if (payloadParamsJson.has(Common.TRTC_USERID)) {
118118
deviceId = payloadParamsJson.getString(Common.TRTC_USERID);
119119
}
120+
if (isCalling) { //被叫
121+
if (payloadParamsJson.has(Common.TRTC_CALLEDID)) {
122+
deviceId = payloadParamsJson.getString(Common.TRTC_CALLEDID);
123+
}
124+
} else { //主叫
125+
if (payloadParamsJson.has(Common.TRTC_CALLERID)) {
126+
deviceId = payloadParamsJson.getString(Common.TRTC_CALLERID);
127+
}
128+
}
120129

121130
String rejectId = "";
122131
if (payloadParamsJson.has(Common.TRTC_EXTRA_INFO)) {

0 commit comments

Comments
 (0)