|
@@ -32,70 +32,72 @@ import com.swago.baseswago.util.UserInfo
|
|
|
*@date 2021/10/10 10:00
|
|
|
*description:
|
|
|
*/
|
|
|
-class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
+class MsgVm(application: Application) : AbsMsgVm(application) {
|
|
|
|
|
|
var isReady = false
|
|
|
|
|
|
- var newChatMsgFun:((iRoomChat:IRoomChat?)->Unit)? = null
|
|
|
+ var newChatMsgFun: ((iRoomChat: IRoomChat?) -> Unit)? = null
|
|
|
|
|
|
- var anchorRoomClosed:((data:AnchorRoomClosedBean?)->Unit)? = null
|
|
|
+ var anchorRoomClosed: ((data: AnchorRoomClosedBean?) -> Unit)? = null
|
|
|
|
|
|
//强制关播
|
|
|
- var forceCloseAnchorRoom:((closedReason:String)->Unit)? = null
|
|
|
+ var forceCloseAnchorRoom: ((closedReason: String) -> Unit)? = null
|
|
|
|
|
|
- var inComeChange:((income:String)->Unit)? = null
|
|
|
+ var inComeChange: ((income: String) -> Unit)? = null
|
|
|
|
|
|
- var updateHotValue:((hotValue:String)->Unit)? = null
|
|
|
+ var updateHotValue: ((hotValue: String) -> Unit)? = null
|
|
|
|
|
|
- var kickFromRoom:(()->Unit)? = null
|
|
|
+ var kickFromRoom: (() -> Unit)? = null
|
|
|
|
|
|
- var forbidSpeakOrCancel:((cancel:Boolean)->Unit)? = null
|
|
|
+ var forbidSpeakOrCancel: ((cancel: Boolean) -> Unit)? = null
|
|
|
|
|
|
- var updateUserRoom:(()->Unit)? = null
|
|
|
+ var updateUserRoom: (() -> Unit)? = null
|
|
|
+
|
|
|
+ var newRedEnvelopeCome: ((redEnvelope: RedEnvelope) -> Unit)? = null
|
|
|
|
|
|
- var newRedEnvelopeCome:((redEnvelope:RedEnvelope)->Unit)? = null
|
|
|
//红包传送门
|
|
|
- var openRedEnvelopPortal:((redEnvelope:RedEnvelope)->Unit)? = null
|
|
|
+ var openRedEnvelopPortal: ((redEnvelope: RedEnvelope) -> Unit)? = null
|
|
|
|
|
|
/**
|
|
|
* 播放svg动画
|
|
|
*/
|
|
|
- var playSvgUrl:((data:IMGiftModel)->Unit)? = null
|
|
|
+ var playSvgUrl: ((data: IMGiftModel) -> Unit)? = null
|
|
|
|
|
|
/**
|
|
|
* 礼物飘条
|
|
|
*/
|
|
|
- var waftFun:((data:IPiaoTiao)->Unit)? = null
|
|
|
+ var waftFun: ((data: IPiaoTiao) -> Unit)? = null
|
|
|
|
|
|
/**
|
|
|
* 礼物弹道展示
|
|
|
*/
|
|
|
- var showGiftDanDao:((data:IMGiftModel)->Unit)? = null
|
|
|
+ var showGiftDanDao: ((data: IMGiftModel) -> Unit)? = null
|
|
|
|
|
|
override fun receiveMsg() {
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<RoomChatMsgBean>>(room_chat_text){
|
|
|
- if (it.getGroupId() == (SwagoRoomManager.iRoomInfo?.getRoomGroupId() ?: "")){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<RoomChatMsgBean>>(room_chat_text) {
|
|
|
+ if (it.getGroupId() == (SwagoRoomManager.iRoomInfo?.getRoomGroupId() ?: "")) {
|
|
|
it.data?.let {
|
|
|
newChatMsgFun?.invoke(it)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<UserJoinRoomBean>>(user_join_room){
|
|
|
- if (it.getGroupId() == (SwagoRoomManager.iRoomInfo?.getRoomGroupId() ?: "")){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<UserJoinRoomBean>>(user_join_room) {
|
|
|
+ if (isReady && it.getGroupId() == (SwagoRoomManager.iRoomInfo?.getRoomGroupId()
|
|
|
+ ?: "")
|
|
|
+ ) {
|
|
|
if (SwagoRoomManager.roleType == RoleType.user || it.data?.senderCode != UserInfo.getUserInfo()?.user_account) {
|
|
|
it.data?.let {
|
|
|
newChatMsgFun?.invoke(it)
|
|
|
updateHotValue?.invoke(it.hotValue)
|
|
|
updateUserRoom?.invoke()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<UserJoinRoomBean>>(user_exit_room){
|
|
|
- if (it.getGroupId() == (SwagoRoomManager.iRoomInfo?.getRoomGroupId() ?: "")){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<UserJoinRoomBean>>(user_exit_room) {
|
|
|
+ if (it.getGroupId() == (SwagoRoomManager.iRoomInfo?.getRoomGroupId() ?: "")) {
|
|
|
if (SwagoRoomManager.roleType == RoleType.user || it.data?.senderCode != UserInfo.getUserInfo()?.user_account) {
|
|
|
it.data?.let {
|
|
|
updateHotValue?.invoke(it.hotValue)
|
|
@@ -106,28 +108,28 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<AnchorRoomClosedBean>>(anchor_close_room){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<AnchorRoomClosedBean>>(anchor_close_room) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
- if (iRoomInfo.getRoomId() == (it.data?.roomId ?: "")){
|
|
|
+ if (iRoomInfo.getRoomId() == (it.data?.roomId ?: "")) {
|
|
|
anchorRoomClosed?.invoke(it.data)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//后台强制关播
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ForceCloseModel>>(force_close_live_room){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ForceCloseModel>>(force_close_live_room) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
- if (iRoomInfo.getRoomId() == (it.data?.roomId ?: "")){
|
|
|
- forceCloseAnchorRoom?.invoke(it.data?.closedReason?:"")
|
|
|
+ if (iRoomInfo.getRoomId() == (it.data?.roomId ?: "")) {
|
|
|
+ forceCloseAnchorRoom?.invoke(it.data?.closedReason ?: "")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<IMGiftModel>>(svg_gift){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<IMGiftModel>>(svg_gift) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
- if (isReady){
|
|
|
+ if (isReady) {
|
|
|
it.data?.let {
|
|
|
- if (iRoomInfo.getRoomId() == (it.roomId ?: "")){
|
|
|
+ if (iRoomInfo.getRoomId() == (it.roomId ?: "")) {
|
|
|
playSvgUrl?.invoke(it)
|
|
|
inComeChange?.invoke(it.incomeCount)
|
|
|
}
|
|
@@ -137,15 +139,15 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<IMGiftModel>>(lucky_gift){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<IMGiftModel>>(lucky_gift) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
- if (isReady){
|
|
|
+ if (isReady) {
|
|
|
it.data?.let {
|
|
|
- if (iRoomInfo.getRoomId() == (it.roomId ?: "")){
|
|
|
+ if (iRoomInfo.getRoomId() == (it.roomId ?: "")) {
|
|
|
showGiftDanDao?.invoke(it)
|
|
|
inComeChange?.invoke(it.incomeCount)
|
|
|
}
|
|
|
- if (it.multiple>=500){
|
|
|
+ if (it.multiple >= 500) {
|
|
|
waftFun?.invoke(it)
|
|
|
}
|
|
|
}
|
|
@@ -154,11 +156,12 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
|
|
|
imGroupNewMsgListener.handleMsgType<CusNewMsgBean<FollowSuccessMsgBean>>(
|
|
|
- follow_anchor_success){
|
|
|
+ follow_anchor_success
|
|
|
+ ) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
- if (isReady){
|
|
|
+ if (isReady) {
|
|
|
it.data?.let {
|
|
|
- if (iRoomInfo.getRoomId() == (it.roomId ?: "")){
|
|
|
+ if (iRoomInfo.getRoomId() == (it.roomId ?: "")) {
|
|
|
newChatMsgFun?.invoke(it)
|
|
|
}
|
|
|
}
|
|
@@ -167,11 +170,11 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ReceiveModel>>(remove_room){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ReceiveModel>>(remove_room) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
UserInfo.getUserInfo()?.let { userInfo ->
|
|
|
it.data?.let {
|
|
|
- if (it.roomId == iRoomInfo.getRoomId()&&it.receiverId==userInfo.id) {
|
|
|
+ if (it.roomId == iRoomInfo.getRoomId() && it.receiverId == userInfo.id) {
|
|
|
kickFromRoom?.invoke()
|
|
|
}
|
|
|
}
|
|
@@ -179,11 +182,11 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ReceiveModel>>(forbid_speak){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ReceiveModel>>(forbid_speak) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
UserInfo.getUserInfo()?.let { userInfo ->
|
|
|
it.data?.let {
|
|
|
- if (it.roomId == iRoomInfo.getRoomId()&&it.receiverId==userInfo.id) {
|
|
|
+ if (it.roomId == iRoomInfo.getRoomId() && it.receiverId == userInfo.id) {
|
|
|
forbidSpeakOrCancel?.invoke(true)
|
|
|
}
|
|
|
}
|
|
@@ -191,11 +194,11 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ReceiveModel>>(cancel_forbid_speak){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<ReceiveModel>>(cancel_forbid_speak) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
UserInfo.getUserInfo()?.let { userInfo ->
|
|
|
it.data?.let {
|
|
|
- if (it.roomId == iRoomInfo.getRoomId()&&it.receiverId==userInfo.id) {
|
|
|
+ if (it.roomId == iRoomInfo.getRoomId() && it.receiverId == userInfo.id) {
|
|
|
forbidSpeakOrCancel?.invoke(false)
|
|
|
}
|
|
|
}
|
|
@@ -204,7 +207,7 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
|
|
|
//红包
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<RedEnvelope>>(red_envelope){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<RedEnvelope>>(red_envelope) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
it.data?.let {
|
|
|
if (it.roomId == iRoomInfo.getRoomId()) {
|
|
@@ -216,10 +219,10 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
|
|
|
//红包全局通知
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<RedEnvelope>>(red_envelope_broadcast){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<RedEnvelope>>(red_envelope_broadcast) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
it.data?.let {
|
|
|
- if (isReady&&it.roomId != iRoomInfo.getRoomId()&&SwagoRoomManager.roleType==RoleType.user) {
|
|
|
+ if (isReady && it.roomId != iRoomInfo.getRoomId() && SwagoRoomManager.roleType == RoleType.user) {
|
|
|
//其他直播间用户收到这个全局红包的通知触发弹窗
|
|
|
openRedEnvelopPortal?.invoke(it)
|
|
|
}
|
|
@@ -227,7 +230,7 @@ class MsgVm (application: Application) : AbsMsgVm(application){
|
|
|
}
|
|
|
}
|
|
|
//游戏中奖飘条
|
|
|
- imGroupNewMsgListener.handleMsgType<CusNewMsgBean<GamePrize>>(game_win_big_prize){
|
|
|
+ imGroupNewMsgListener.handleMsgType<CusNewMsgBean<GamePrize>>(game_win_big_prize) {
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
it.data?.let {
|
|
|
if (isReady) {
|