Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
981a851d
Commit
981a851d
authored
May 23, 2022
by
罗长华
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/xiaohudou_20220427' into xiaohudou_20220427
parents
75e4555b
373df364
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
272 additions
and
1 deletions
+272
-1
core/src/main/java/com/wecloud/im/entity/ImRtcRecord.java
+64
-0
core/src/main/java/com/wecloud/im/mapper/ImRtcRecordMapper.java
+15
-0
core/src/main/java/com/wecloud/im/sdk/enums/RtcStateEnum.java
+45
-0
core/src/main/java/com/wecloud/im/service/ImRtcRecordService.java
+28
-0
core/src/main/java/com/wecloud/im/service/impl/ImRtcRecordServiceImpl.java
+83
-0
core/src/main/java/com/wecloud/rtc/service/impl/RtcServiceImpl.java
+18
-0
docs/db/feature-cluster增量.sql
+19
-1
No files found.
core/src/main/java/com/wecloud/im/entity/ImRtcRecord.java
0 → 100644
View file @
981a851d
package
com
.
wecloud
.
im
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.geekidea.springbootplus.framework.common.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
/**
* @Author Future
* @Date 2022/5/22 23:40
* @Description 单人音视频记录表
*/
@Data
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@ApiModel
(
value
=
"单人音视频记录"
)
public
class
ImRtcRecord
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
-
523597842194055670L
;
@NotNull
(
message
=
"主键id不能为空"
)
@ApiModelProperty
(
"主键id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
private
Long
id
;
@ApiModelProperty
(
"应用appid"
)
private
Long
fkAppid
;
@ApiModelProperty
(
"频道id"
)
private
Long
channelId
;
@ApiModelProperty
(
"发起方clientId"
)
private
String
fromClientId
;
@ApiModelProperty
(
"接收方clientId"
)
private
String
toClientId
;
/**
* 单人音视频状态枚举
* @see com.wecloud.im.sdk.enums.RtcStateEnum
*/
@ApiModelProperty
(
"频道状态,1:音视频发起,2:音视频中,3:音视频结束"
)
private
Integer
state
;
@ApiModelProperty
(
"音视频开始时间"
)
private
Date
startTime
;
@ApiModelProperty
(
"音视频结束时间"
)
private
Date
endTime
;
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"修改时间"
)
private
Date
updateTime
;
}
core/src/main/java/com/wecloud/im/mapper/ImRtcRecordMapper.java
0 → 100644
View file @
981a851d
package
com
.
wecloud
.
im
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.wecloud.im.entity.ImRtcRecord
;
import
org.springframework.stereotype.Repository
;
/**
* @Author Future
* @Date 2022/5/22 23:49
* @Description 单人音视频记录mapper
*/
@Repository
public
interface
ImRtcRecordMapper
extends
BaseMapper
<
ImRtcRecord
>
{
}
core/src/main/java/com/wecloud/im/sdk/enums/RtcStateEnum.java
0 → 100644
View file @
981a851d
package
com
.
wecloud
.
im
.
sdk
.
enums
;
import
io.geekidea.springbootplus.framework.common.enums.BaseEnum
;
/**
* @Author Future
* @Date 2022/5/22 23:42
* @Description 单人音视频状态枚举
*/
public
enum
RtcStateEnum
implements
BaseEnum
{
/**
* 1 - 音视频发起
*/
CREATED
(
1
,
"音视频发起"
),
/**
* 2 - 音视频中
*/
ING
(
2
,
"音视频中"
),
/**
* 3 - 音视频结束
*/
END
(
3
,
"音视频结束"
);
RtcStateEnum
(
int
code
,
String
desc
)
{
this
.
code
=
code
;
this
.
desc
=
desc
;
}
private
final
Integer
code
;
private
final
String
desc
;
@Override
public
Integer
getCode
()
{
return
this
.
code
;
}
@Override
public
String
getDesc
()
{
return
this
.
desc
;
}
}
core/src/main/java/com/wecloud/im/service/ImRtcRecordService.java
0 → 100644
View file @
981a851d
package
com
.
wecloud
.
im
.
service
;
import
com.wecloud.im.entity.ImRtcRecord
;
import
com.wecloud.im.param.rtc.CreateRtcChannelParam
;
import
io.geekidea.springbootplus.framework.common.service.BaseService
;
/**
* @Author wenzhida
* @Date 2022/3/16 9:08
* @Description 单人音视频房记录服务接口
*/
public
interface
ImRtcRecordService
extends
BaseService
<
ImRtcRecord
>
{
/**
* 创建rtc通话记录
* @param param
* @param channelId
*/
void
createRtcRecord
(
CreateRtcChannelParam
param
,
Long
channelId
);
/**
* 更新音视频记录
* @param channelId
* @param type 1-同意进入频道 2-拒接进入频道 3-主动挂断(离开频道)
*/
void
updateRtcRecord
(
Long
channelId
,
Integer
type
);
}
core/src/main/java/com/wecloud/im/service/impl/ImRtcRecordServiceImpl.java
0 → 100644
View file @
981a851d
package
com
.
wecloud
.
im
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImRtcRecord
;
import
com.wecloud.im.mapper.ImRtcRecordMapper
;
import
com.wecloud.im.param.rtc.CreateRtcChannelParam
;
import
com.wecloud.im.sdk.enums.RtcStateEnum
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImRtcRecordService
;
import
com.wecloud.utils.SnowflakeUtil
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
/**
* @Author Future
* @Date 2022/5/22 23:50
* @Description 单人音视频记录服务实现
*/
@Slf4j
@Service
public
class
ImRtcRecordServiceImpl
extends
BaseServiceImpl
<
ImRtcRecordMapper
,
ImRtcRecord
>
implements
ImRtcRecordService
{
@Autowired
private
ImClientService
imClientService
;
@Override
public
void
createRtcRecord
(
CreateRtcChannelParam
param
,
Long
channelId
)
{
try
{
ImClient
currentClient
=
imClientService
.
getCurrentClient
();
ImRtcRecord
rtcRecord
=
new
ImRtcRecord
();
rtcRecord
.
setId
(
SnowflakeUtil
.
getId
());
rtcRecord
.
setFkAppid
(
currentClient
.
getFkAppid
());
rtcRecord
.
setChannelId
(
channelId
);
rtcRecord
.
setFromClientId
(
currentClient
.
getClientId
());
rtcRecord
.
setToClientId
(
param
.
getToClient
());
rtcRecord
.
setState
(
RtcStateEnum
.
CREATED
.
getCode
());
rtcRecord
.
setCreateTime
(
new
Date
());
this
.
save
(
rtcRecord
);
}
catch
(
Exception
e
)
{
log
.
info
(
"创建rtc通话记录异常 param {} channelId {} 异常 "
,
JSON
.
toJSONString
(
param
),
channelId
,
e
);
}
}
/**
* 更新音视频记录
*
* @param channelId
* @param type 1-同意进入频道 2-拒接进入频道 3-主动挂断(离开频道)
*/
@Override
public
void
updateRtcRecord
(
Long
channelId
,
Integer
type
)
{
try
{
ImRtcRecord
rtcRecord
=
this
.
getById
(
channelId
);
if
(
rtcRecord
==
null
)
{
return
;
}
if
(
type
==
1
)
{
// 同意进入频道
rtcRecord
.
setState
(
RtcStateEnum
.
ING
.
getCode
());
rtcRecord
.
setStartTime
(
new
Date
());
}
else
if
(
type
==
2
)
{
// 拒接进入频道
rtcRecord
.
setState
(
RtcStateEnum
.
END
.
getCode
());
}
else
{
// 主动挂断(离开频道)
rtcRecord
.
setState
(
RtcStateEnum
.
END
.
getCode
());
rtcRecord
.
setEndTime
(
new
Date
());
}
this
.
updateById
(
rtcRecord
);
}
catch
(
Exception
e
)
{
log
.
info
(
"更新rtc通话记录异常, channelId {}, type {} 异常 "
,
channelId
,
type
,
e
);
}
}
}
core/src/main/java/com/wecloud/rtc/service/impl/RtcServiceImpl.java
View file @
981a851d
...
@@ -6,6 +6,7 @@ import com.wecloud.im.param.rtc.*;
...
@@ -6,6 +6,7 @@ import com.wecloud.im.param.rtc.*;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientBlacklistService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImRtcRecordService
;
import
com.wecloud.im.ws.cache.UserStateCacheManager
;
import
com.wecloud.im.ws.cache.UserStateCacheManager
;
import
com.wecloud.im.ws.cache.UserStateListener
;
import
com.wecloud.im.ws.cache.UserStateListener
;
import
com.wecloud.rtc.entity.response.*
;
import
com.wecloud.rtc.entity.response.*
;
...
@@ -47,6 +48,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
...
@@ -47,6 +48,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
@Autowired
@Autowired
private
ImClientBlacklistService
imClientBlacklistService
;
private
ImClientBlacklistService
imClientBlacklistService
;
@Autowired
private
ImRtcRecordService
imRtcRecordService
;
@Override
@Override
public
void
onLineEvent
(
Long
client
,
Integer
platform
,
String
longChannelId
)
{
public
void
onLineEvent
(
Long
client
,
Integer
platform
,
String
longChannelId
)
{
// nothing need to do
// nothing need to do
...
@@ -101,6 +105,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
...
@@ -101,6 +105,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
wsRtcWrite
.
rtcCall
(
rtcCallResponse
,
toClient
.
getId
());
wsRtcWrite
.
rtcCall
(
rtcCallResponse
,
toClient
.
getId
());
// 创建通话记录 todo 优化为mq推送
imRtcRecordService
.
createRtcRecord
(
createRtcChannelParam
,
createRtcChannelResult
.
getChannelId
());
// TODO 待开发 下发安卓和ios系统推送
// TODO 待开发 下发安卓和ios系统推送
return
createRtcChannelResult
;
return
createRtcChannelResult
;
...
@@ -132,6 +139,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
...
@@ -132,6 +139,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
wsRtcWrite
.
clientJoin
(
rtcSdpForwardResponse
,
Long
.
valueOf
(
toClientId
));
wsRtcWrite
.
clientJoin
(
rtcSdpForwardResponse
,
Long
.
valueOf
(
toClientId
));
}
}
// 更新通话记录 todo 优化为mq推送
imRtcRecordService
.
updateRtcRecord
(
joinRtcChannelParam
.
getChannelId
(),
1
);
return
true
;
return
true
;
}
}
...
@@ -162,6 +172,10 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
...
@@ -162,6 +172,10 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
mangerRtcCacheService
.
leave
(
Long
.
valueOf
(
clientListByRtcChannelId
.
get
(
0
)),
rejectRtcChannelParam
.
getChannelId
());
mangerRtcCacheService
.
leave
(
Long
.
valueOf
(
clientListByRtcChannelId
.
get
(
0
)),
rejectRtcChannelParam
.
getChannelId
());
mangerRtcCacheService
.
delChannelInfo
(
rejectRtcChannelParam
.
getChannelId
());
mangerRtcCacheService
.
delChannelInfo
(
rejectRtcChannelParam
.
getChannelId
());
}
}
// 更新通话记录 todo 优化为mq推送
imRtcRecordService
.
updateRtcRecord
(
rejectRtcChannelParam
.
getChannelId
(),
2
);
return
true
;
return
true
;
}
}
...
@@ -169,6 +183,10 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
...
@@ -169,6 +183,10 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
public
Boolean
leave
(
LeaveRtcChannelParam
leaveRtcChannelParam
)
{
public
Boolean
leave
(
LeaveRtcChannelParam
leaveRtcChannelParam
)
{
ImClient
currentClient
=
imClientService
.
getCurrentClient
();
ImClient
currentClient
=
imClientService
.
getCurrentClient
();
this
.
leave
(
leaveRtcChannelParam
,
currentClient
);
this
.
leave
(
leaveRtcChannelParam
,
currentClient
);
// 更新通话记录 todo 优化为mq推送
imRtcRecordService
.
updateRtcRecord
(
leaveRtcChannelParam
.
getChannelId
(),
3
);
return
true
;
return
true
;
}
}
...
...
docs/db/feature-cluster增量.sql
View file @
981a851d
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
...
@@ -161,5 +161,23 @@ ALTER TABLE im_conversation
...
@@ -161,5 +161,23 @@ ALTER TABLE im_conversation
DROP
TABLE
IF
EXISTS
`im_rtc_record`
;
CREATE
TABLE
`im_rtc_record`
(
`id`
bigint
NOT
NULL
COMMENT
'主键id'
,
`fk_appid`
bigint
DEFAULT
NULL
COMMENT
'应用appid'
,
`channel_id`
bigint
DEFAULT
NULL
COMMENT
'频道id'
,
`from_client_id`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'发起方clientId'
,
`to_client_id`
varchar
(
200
)
DEFAULT
NULL
COMMENT
'接收方clientId'
,
`state`
tinyint
NOT
NULL
DEFAULT
'1'
COMMENT
'频道状态,1:音视频发起,2:音视频中,3:音视频结束'
,
`start_time`
timestamp
NULL
DEFAULT
NULL
COMMENT
'音视频开始时间'
,
`end_time`
timestamp
NULL
DEFAULT
NULL
COMMENT
'音视频结束时间'
,
`create_time`
timestamp
NULL
DEFAULT
NULL
COMMENT
'创建时间'
,
`update_time`
timestamp
NULL
DEFAULT
NULL
ON
UPDATE
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
KEY
`idx_channel_id`
(
`channel_id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'单人音视频聊天记录表'
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment