🔊 Verbose websocket connection logging
This commit is contained in:
parent
ab9bc5d127
commit
90741379d6
@ -32,7 +32,10 @@ func (v *Server) PushStream(ctx context.Context, request *proto.PushStreamReques
|
|||||||
log.Debug().
|
log.Debug().
|
||||||
Uint64("client_id", request.GetClientId()).
|
Uint64("client_id", request.GetClientId()).
|
||||||
Uint64("user_id", request.GetUserId()).
|
Uint64("user_id", request.GetUserId()).
|
||||||
Msgf("Pushing a websocket package to client / user...")
|
Int("count", cnt).
|
||||||
|
Int("success", success).
|
||||||
|
Int("failed", len(errs)).
|
||||||
|
Msgf("Pushed a websocket package to client / user...")
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
// Partial fail
|
// Partial fail
|
||||||
@ -72,6 +75,14 @@ func (v *Server) PushStreamBatch(ctx context.Context, request *proto.PushStreamB
|
|||||||
errs = append(errs, cErrs...)
|
errs = append(errs, cErrs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debug().
|
||||||
|
Any("client_id", request.GetClientId()).
|
||||||
|
Any("user_id", request.GetUserId()).
|
||||||
|
Int("count", cnt).
|
||||||
|
Int("success", success).
|
||||||
|
Int("failed", len(errs)).
|
||||||
|
Msgf("Pushed a websocket package to client / user...")
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
// Partial fail
|
// Partial fail
|
||||||
return &proto.PushStreamResponse{
|
return &proto.PushStreamResponse{
|
||||||
|
@ -3,6 +3,7 @@ package ws
|
|||||||
import (
|
import (
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
|
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -23,7 +24,12 @@ func ClientRegister(user sec.UserInfo, conn *websocket.Conn) uint64 {
|
|||||||
wsConn[user.ID][clientId] = conn
|
wsConn[user.ID][clientId] = conn
|
||||||
wsMutex.Unlock()
|
wsMutex.Unlock()
|
||||||
|
|
||||||
directory.BroadcastEvent("ws.client.register", map[string]any{
|
log.Debug().
|
||||||
|
Uint64("client_id", clientId).
|
||||||
|
Uint("user_id", user.ID).
|
||||||
|
Msg("An client connected to stream endpoint...")
|
||||||
|
|
||||||
|
_ = directory.BroadcastEvent("ws.client.register", map[string]any{
|
||||||
"user": user.ID,
|
"user": user.ID,
|
||||||
"id": clientId,
|
"id": clientId,
|
||||||
})
|
})
|
||||||
@ -39,6 +45,11 @@ func ClientUnregister(user sec.UserInfo, id uint64) {
|
|||||||
delete(wsConn[user.ID], id)
|
delete(wsConn[user.ID], id)
|
||||||
wsMutex.Unlock()
|
wsMutex.Unlock()
|
||||||
|
|
||||||
|
log.Debug().
|
||||||
|
Uint64("client_id", id).
|
||||||
|
Uint("user_id", user.ID).
|
||||||
|
Msg("An client disconnected from stream endpoint...")
|
||||||
|
|
||||||
_ = directory.BroadcastEvent("ws.client.unregister", map[string]any{
|
_ = directory.BroadcastEvent("ws.client.unregister", map[string]any{
|
||||||
"user": user.ID,
|
"user": user.ID,
|
||||||
"id": id,
|
"id": id,
|
||||||
|
Loading…
Reference in New Issue
Block a user