fix: 测试 WS 客户端按字节流拆包并恢复群事件同步下发
This commit is contained in:
@@ -892,7 +892,6 @@ 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,
|
||||
@@ -901,20 +900,14 @@ func (a *App) emit(ctx context.Context, recipients []string, groupID, event, end
|
||||
if encErr != nil {
|
||||
return
|
||||
}
|
||||
// 异步且略推迟:必须让处理该端上行的 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 := map[string]struct{}{}
|
||||
for _, id := range recipients {
|
||||
if _, ok := seen[id]; ok {
|
||||
continue
|
||||
}
|
||||
}()
|
||||
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