test: 补齐短时间可测验收并修复建群下行卡住
This commit is contained in:
@@ -660,6 +660,7 @@ func (a *App) emit(ctx context.Context, recipients []string, groupID, event, end
|
||||
if a.down == nil {
|
||||
return
|
||||
}
|
||||
_ = ctx
|
||||
frame := protocol.GroupEvent{
|
||||
V: protocol.Version, Type: protocol.TypeGroupEvent,
|
||||
GroupID: groupID, Event: event, EndpointID: endpointID, AtMs: atMs,
|
||||
@@ -668,14 +669,20 @@ func (a *App) emit(ctx context.Context, recipients []string, groupID, event, end
|
||||
if encErr != nil {
|
||||
return
|
||||
}
|
||||
seen := map[string]struct{}{}
|
||||
for _, id := range recipients {
|
||||
if _, ok := seen[id]; ok {
|
||||
continue
|
||||
// 异步且略推迟:必须让处理该端上行的 worker 先 PublishDown resp。
|
||||
// 若与 resp 同时向本连接注入 group_event,会与 mochi InlineClient 互相等待。
|
||||
ids := append([]string(nil), recipients...)
|
||||
go func() {
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
seen := map[string]struct{}{}
|
||||
for _, id := range ids {
|
||||
if _, ok := seen[id]; ok {
|
||||
continue
|
||||
}
|
||||
seen[id] = struct{}{}
|
||||
_ = a.down.PublishDown(context.Background(), id, "", payload, port.PublishOpts{QoS: 0})
|
||||
}
|
||||
seen[id] = struct{}{}
|
||||
_ = a.down.PublishDown(ctx, id, "", payload, port.PublishOpts{QoS: 0})
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func encodeFrame(v any) ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user