Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
hujiebin
hilo-group
Commits
4bddac36
Commit
4bddac36
authored
Mar 09, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:上麦调成发事件
parent
363408c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
6 deletions
+64
-6
on_mic.go
cron/mic_cron/on_mic.go
+15
-5
on_mic.go
domain/event/mic_ev/on_mic.go
+29
-0
event_init.go
domain/service/event_s/event_init.go
+20
-1
No files found.
cron/mic_cron/on_mic.go
View file @
4bddac36
...
...
@@ -3,8 +3,8 @@ package mic_cron
import
(
"git.hilo.cn/hilo-common/domain"
"github.com/robfig/cron"
"hilo-group/domain/event/mic_ev"
"hilo-group/domain/model/group_m"
"hilo-group/domain/service/group_mic_s"
)
func
OnMicCheck
()
{
...
...
@@ -27,11 +27,21 @@ func OnMicCheck() {
model
.
Log
.
Errorf
(
"cron micIn group_m.GetMicUser err:%v"
,
err
)
}
if
micUser
!=
nil
{
if
err
:=
group_mic_s
.
NewGroupPowerService
(
model
.
MyContext
)
.
GroupPowerOnMicExp
(
groupId
,
micUser
.
UserId
,
micUser
.
Timestamp
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"cron micIn GroupPowerOnMicExp err:%v"
,
err
)
}
else
{
model
.
Log
.
Infof
(
"cron micIn GroupPowerOnMicExp success, groupId:%v, userId:%v"
,
groupId
,
micUser
.
UserId
)
if
err
:=
mic_ev
.
PublishOnMicEvent
(
model
,
&
mic_ev
.
OnMicEvent
{
GroupUuid
:
micUser
.
GroupUuid
,
I
:
micUser
.
I
,
ExternalId
:
micUser
.
ExternalId
,
UserId
:
micUser
.
UserId
,
Forbid
:
micUser
.
Forbid
,
Timestamp
:
micUser
.
Timestamp
,
});
err
!=
nil
{
model
.
Log
.
Errorf
(
"PublishOnMicEvent fail:%v"
,
err
)
}
//if err := group_mic_s.NewGroupPowerService(model.MyContext).GroupPowerOnMicExp(groupId, micUser.UserId, micUser.Timestamp); err != nil {
// model.Log.Errorf("cron micIn GroupPowerOnMicExp err:%v", err)
//} else {
// model.Log.Infof("cron micIn GroupPowerOnMicExp success, groupId:%v, userId:%v", groupId, micUser.UserId)
//}
}
}
}
...
...
domain/event/mic_ev/on_mic.go
0 → 100644
View file @
4bddac36
package
mic_ev
import
(
"git.hilo.cn/hilo-common/domain"
)
var
onMicListen
=
new
(
domain
.
EventBase
)
// 在麦上事件
type
OnMicEvent
struct
{
GroupUuid
string
// 群组uuid
I
int
// 麦位
ExternalId
string
// 麦中的人
UserId
uint64
// 麦中的人
Forbid
bool
// 静音 true:静音,false:没有静音
Timestamp
int64
// 上麦的的时间戳
}
func
AddOnMicEventSync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventSync
(
onMicListen
,
callback
)
}
func
AddOnMicEventAsync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventAsync
(
onMicListen
,
callback
)
}
func
PublishOnMicEvent
(
model
*
domain
.
Model
,
event
interface
{})
error
{
return
domain
.
PublishEvent
(
onMicListen
,
model
,
event
)
}
domain/service/event_s/event_init.go
View file @
4bddac36
...
...
@@ -13,12 +13,14 @@ import (
"hilo-group/domain/event/gift_ev"
"hilo-group/domain/event/group_ev"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/event/mic_ev"
"hilo-group/domain/model/diamond_m"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/group_m"
"hilo-group/domain/model/msg_m"
"hilo-group/domain/model/task_m"
"hilo-group/domain/model/user_m"
"hilo-group/domain/service/group_mic_s"
"hilo-group/myerr"
"strconv"
"time"
...
...
@@ -30,7 +32,8 @@ func EventInit() {
GroupEvents
()
GroupImMass
()
GroupTheme
()
SendGift
()
SendGift
()
// 送礼事件
OnMic
()
// 在麦上事件
}
func
GroupSupportEvents
()
{
...
...
@@ -451,3 +454,19 @@ func SendGift() {
return
nil
})
}
func
OnMic
()
{
mic_ev
.
AddOnMicEventSync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
event
,
ok
:=
e
.
(
*
mic_ev
.
OnMicEvent
)
if
!
ok
{
model
.
Log
.
Errorf
(
"AddOnMicEventSync event type err"
)
return
nil
}
if
err
:=
group_mic_s
.
NewGroupPowerService
(
model
.
MyContext
)
.
GroupPowerOnMicExp
(
event
.
GroupUuid
,
event
.
UserId
,
event
.
Timestamp
);
err
!=
nil
{
model
.
Log
.
Errorf
(
"cron micIn GroupPowerOnMicExp err:%v"
,
err
)
}
else
{
model
.
Log
.
Infof
(
"cron micIn GroupPowerOnMicExp success, groupId:%v, userId:%v"
,
event
.
GroupUuid
,
event
.
UserId
)
}
return
nil
})
}
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