feat(call): integrate LiveKit for voice and video calling
Replace the manual WebRTC signaling implementation with LiveKit SFU. This includes: - Adding LiveKit service, handler, and configuration. - Updating Docker Compose to include LiveKit server, Redis, and PostgreSQL. - Refactoring `CallService` and `WSHandler` to support LiveKit room readiness instead of raw SDP/ICE relaying. - Adding new API endpoints for LiveKit token generation and webhooks. - Removing deprecated WebRTC configuration and manual signaling DTOs.
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
package crypto
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// BatchDecryptResult 批量解密结果
|
||||
type BatchDecryptResult struct {
|
||||
Index int
|
||||
Plaintext []byte
|
||||
Error error
|
||||
}
|
||||
|
||||
// BatchDecrypt 批量并行解密
|
||||
// workerCount 指定并行工作数,如果 <= 0 则使用 CPU 核数
|
||||
func (e *MessageEncryptor) BatchDecrypt(ciphertexts []string, workerCount int) [][]byte {
|
||||
if e == nil || len(ciphertexts) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
results := make([][]byte, len(ciphertexts))
|
||||
|
||||
// 小批量直接串行处理
|
||||
if len(ciphertexts) <= 10 {
|
||||
for i, ct := range ciphertexts {
|
||||
if ct == "" {
|
||||
continue
|
||||
}
|
||||
plaintext, err := e.Decrypt(ct)
|
||||
if err == nil {
|
||||
results[i] = plaintext
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
// 并行处理
|
||||
jobs := make(chan int, len(ciphertexts))
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// 确定工作数
|
||||
if workerCount <= 0 {
|
||||
workerCount = 4 // 默认4个并行
|
||||
}
|
||||
if workerCount > len(ciphertexts) {
|
||||
workerCount = len(ciphertexts)
|
||||
}
|
||||
|
||||
// 启动 worker
|
||||
for w := 0; w < workerCount; w++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for i := range jobs {
|
||||
ct := ciphertexts[i]
|
||||
if ct == "" {
|
||||
continue
|
||||
}
|
||||
plaintext, err := e.Decrypt(ct)
|
||||
if err == nil {
|
||||
results[i] = plaintext
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// 分发任务
|
||||
for i := range ciphertexts {
|
||||
jobs <- i
|
||||
}
|
||||
close(jobs)
|
||||
|
||||
wg.Wait()
|
||||
return results
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ func (h *Hub) PublishToUserOnline(userID string, eventType string, payload any)
|
||||
}
|
||||
|
||||
// PublishToUserOnlineReliable 可靠地发送事件给在线用户(阻塞发送)
|
||||
// 用于重要的信令消息(如 SDP, ICE candidate),确保消息送达
|
||||
// 用于重要的信令消息(如通话邀请、接听),确保消息送达
|
||||
// 如果用户不在线,返回 false
|
||||
func (h *Hub) PublishToUserOnlineReliable(userID string, eventType string, payload any) bool {
|
||||
h.mu.RLock()
|
||||
|
||||
Reference in New Issue
Block a user