Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
a11671e2
Commit
a11671e2
authored
Dec 28, 2024
by
DavidHuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户进入 直播间提醒
parent
ed038d84
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
21 deletions
+62
-21
YHLivePlayerViewController.swift
.../LivestreamSales(直播销售)/C/YHLivePlayerViewController.swift
+31
-13
YHIMHelper.swift
...ses/Modules/LivestreamSales(直播销售)/IM(环信)/YHIMHelper.swift
+20
-8
YHLiveMessageCell.swift
...s/Modules/LivestreamSales(直播销售)/V/YHLiveMessageCell.swift
+6
-0
YHLiveMessageListView.swift
...dules/LivestreamSales(直播销售)/V/YHLiveMessageListView.swift
+5
-0
No files found.
galaxy/galaxy/Classes/Modules/LivestreamSales(直播销售)/C/YHLivePlayerViewController.swift
View file @
a11671e2
...
...
@@ -305,6 +305,13 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
}
private
func
setupLiveNotifications
()
{
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didUserEnterRoomMessages(_:)
)
,
name
:
YHIMHelper
.
didUserEnterRoomMessages
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didChatManagerReceiveMessages(_:)
)
,
...
...
@@ -328,7 +335,6 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didLoginYH
)
,
name
:
YhConstant
.
YhNotification
.
didLoginSuccessNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didLogOutYH
)
,
name
:
YhConstant
.
YhNotification
.
didLogoutSuccessNotifiction
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
didJoinedOfUid
)
,
name
:
Notification
.
Name
(
"com.YHPlayerManager.didJoinedOfUid"
),
object
:
nil
)
}
// MARK: - Public Methods
...
...
@@ -594,7 +600,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
}
}
}
private
func
checkLogin
()
->
Bool
{
if
!
YHLoginManager
.
shared
.
isLogin
()
{
YHOneKeyLoginManager
.
shared
.
oneKeyLogin
()
...
...
@@ -604,17 +610,6 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
}
// MARK: - Notification Handlers
@objc
private
func
didJoinedOfUid
()
{
let
videoCanvas
=
AgoraRtcVideoCanvas
()
videoCanvas
.
uid
=
playbackInfo
?
.
uid
??
0
videoCanvas
.
view
=
playerView
videoCanvas
.
renderMode
=
.
fit
videoCanvas
.
backgroundColor
=
0x000000
let
ret
=
YHPlayerManager
.
shared
.
agoraKit
.
setupRemoteVideo
(
videoCanvas
)
printLog
(
ret
)
}
@objc
private
func
didChatManagerReceiveMessages
(
_
note
:
Notification
)
{
guard
let
messages
=
note
.
object
as?
[
EMChatMessage
],
let
message
=
messages
.
first
,
...
...
@@ -630,6 +625,29 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
}
}
}
//用户进入直播间通知
@objc
private
func
didUserEnterRoomMessages
(
_
note
:
Notification
)
{
guard
let
messages
=
note
.
object
as?
String
else
{
return
}
appendUserEnterRoomMessage
(
messages
)
}
private
func
appendUserEnterRoomMessage
(
_
userName
:
String
)
{
messageQueue
.
async
{
let
body
=
EMCustomMessageBody
(
event
:
YHChatRoomCustomLocal
.
userEnterRoomEvent
,
customExt
:
[
YHChatRoomCustomLocal
.
userEnterRoomEvent
:
userName
])
let
message
=
EMChatMessage
(
conversationID
:
self
.
roomId
??
""
,
body
:
body
,
ext
:
nil
)
message
.
chatType
=
.
chatRoom
DispatchQueue
.
main
.
async
{
self
.
messageListView
.
addMessages
([
message
])
}
}
}
private
func
updateLiveDetailWith
(
event
:
YHChatRoomCustomEvent
)
{
viewModel
.
getLiveDetail
(
id
:
liveId
)
{
[
weak
self
]
liveDetail
,
error
in
...
...
galaxy/galaxy/Classes/Modules/LivestreamSales(直播销售)/IM(环信)/YHIMHelper.swift
View file @
a11671e2
...
...
@@ -25,12 +25,14 @@ enum YHChatRoomCustomEvent: String {
struct
YHChatRoomCustomLocal
{
static
let
tipsEvent
=
"YHLiveRoomTips"
static
let
tipsKey
=
"tips"
static
let
userEnterRoomEvent
=
"userEnterRoomEvent"
//用户进入聊天室 事件
}
class
YHIMHelper
:
NSObject
{
static
let
didLoginEaseIMSuccess
=
Notification
.
Name
(
"com.YHIMHelper.didLoginEaseIMSuccess"
)
static
let
didLogOutEaseIM
=
Notification
.
Name
(
"com.YHIMHelper.didLogOutEaseIM"
)
static
let
didChatManagerReceiveMessages
=
Notification
.
Name
(
"com.YHIMHelper.didChatManagerReceiveMessages"
)
static
let
didUserEnterRoomMessages
=
Notification
.
Name
(
"com.YHIMHelper.didUserEnterRoomMessages"
)
//用户进入直播间
private
let
viewModel
=
YHLiveSalesViewModel
()
var
isCurrentUserLogin
:
Bool
{
...
...
@@ -222,7 +224,8 @@ extension YHIMHelper {
/// 加入聊天室
func
joinChatRoom
(
roomID
:
String
,
leaveOtherRooms
:
Bool
,
completion
:
@escaping
(
EMError
?)
->
Void
)
{
printLog
(
"joinChatRoom:
\(
currentNickname
)
"
)
EMClient
.
shared
()
.
roomManager
?
.
joinChatroom
(
roomID
,
ext
:
"fromNickName=
\(
currentNickname
)
"
,
leaveOtherRooms
:
leaveOtherRooms
,
completion
:
{
_
,
err
in
let
jsonString
=
[
"fromNickName"
:
currentNickname
]
.
jsonString
()
EMClient
.
shared
()
.
roomManager
?
.
joinChatroom
(
roomID
,
ext
:
jsonString
,
leaveOtherRooms
:
leaveOtherRooms
,
completion
:
{
_
,
err
in
DispatchQueue
.
main
.
async
{
if
let
err
=
err
{
printLog
(
err
.
errorDescription
)
...
...
@@ -274,19 +277,28 @@ extension YHIMHelper {
extension
YHIMHelper
:
EMChatroomManagerDelegate
{
func
userDidJoin
(
_
aChatroom
:
EMChatroom
,
user
aUsername
:
String
,
ext
:
String
?)
{
printLog
(
"
\(
aChatroom
)
加入聊天室了1"
)
printLog
(
"
\(
aChatroom
)
加入聊天室了1 ext =
\(
ext
??
""
)
"
)
if
let
jsonString
=
ext
{
let
dic
=
jsonString
.
toDictionary
()
if
let
fromNickName
=
dic
[
"fromNickName"
]
{
print
(
fromNickName
)
NotificationCenter
.
default
.
post
(
name
:
YHIMHelper
.
didUserEnterRoomMessages
,
object
:
fromNickName
)
return
}
}
}
func
userDid
Join
(
_
aChatroom
:
EMChatroom
,
user
aUsername
:
String
)
{
func
userDid
Leave
(
_
aChatroom
:
EMChatroom
,
user
aUsername
:
String
)
{
let
memberCount
=
aChatroom
.
occupantsCount
printLog
(
memberCount
)
printLog
(
"
\(
aUsername
)
加入 聊天室了2
"
)
printLog
(
"
\(
aUsername
)
离开 聊天室了1111
"
)
}
func
userDidLeave
(
_
aChatroom
:
EMChatroom
,
user
aUsername
:
String
)
{
func
userDidLeave
(
_
aChatroom
:
EMChatroom
,
user
aUsername
:
String
,
ext
:
String
?
)
{
let
memberCount
=
aChatroom
.
occupantsCount
printLog
(
memberCount
)
printLog
(
"
\(
aUsername
)
离开 聊天室了"
)
printLog
(
"
\(
aUsername
)
离开 聊天室了
2222
"
)
}
}
...
...
galaxy/galaxy/Classes/Modules/LivestreamSales(直播销售)/V/YHLiveMessageCell.swift
View file @
a11671e2
...
...
@@ -92,4 +92,10 @@ class YHLiveMessageCell: UITableViewCell {
let
contentAtt
=
(
tipsIcon
+
ASAttributedString
(
string
:
"
\(
tips
)
"
,
.
foreground
(
UIColor
.
white
),
.
font
(
UIFont
.
PFSC_R
(
ofSize
:
13
))))
contentLabel
.
attributed
.
text
=
contentAtt
}
func
configureUserEnterRoomMessage
(
_
usename
:
String
)
{
let
contentAtt
=
(
ASAttributedString
(
string
:
"
\(
usename
)
"
,
.
foreground
(
UIColor
.
brandMainColor
),
.
font
(
UIFont
.
PFSC_R
(
ofSize
:
13
))))
contentLabel
.
attributed
.
text
=
contentAtt
}
}
galaxy/galaxy/Classes/Modules/LivestreamSales(直播销售)/V/YHLiveMessageListView.swift
View file @
a11671e2
...
...
@@ -116,13 +116,18 @@ extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource {
highlight
=
ext
[
"replyTo"
]
as?
String
??
""
}
if
let
body
=
message
.
body
as?
EMTextMessageBody
,
body
.
type
==
.
text
{
//IM 文本消息
printLog
(
body
.
text
)
printLog
(
"
\(
nickName
)
:
\(
body
.
text
)
"
)
content
=
body
.
text
let
isAnchor
=
nickName
==
anchorName
cell
.
configureNormalMessage
(
nickName
,
content
,
highlightTxt
:
highlight
,
isAnchor
:
isAnchor
)
}
else
if
let
body
=
message
.
body
as?
EMCustomMessageBody
,
body
.
event
==
YHChatRoomCustomLocal
.
tipsEvent
,
let
customExt
=
body
.
customExt
,
let
tips
=
customExt
[
YHChatRoomCustomLocal
.
tipsKey
]
{
//直播间提示消息
cell
.
configureTipsMessage
(
tips
)
}
else
if
let
body
=
message
.
body
as?
EMCustomMessageBody
,
body
.
event
==
YHChatRoomCustomLocal
.
userEnterRoomEvent
,
let
customExt
=
body
.
customExt
,
let
userName
=
customExt
[
YHChatRoomCustomLocal
.
userEnterRoomEvent
]
{
//用户加入直播间消息
cell
.
configureUserEnterRoomMessage
(
userName
)
}
return
cell
...
...
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