mirror of
https://github.com/Kyren223/eko.git
synced 2026-08-26 17:41:30 +00:00
Added better logging for packets and payloads and now the writer is
responsible for packaging into a packet the payload (instead of everyone who sends to the writer)
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
||||
|
||||
"github.com/kyren223/eko/internal/data"
|
||||
"github.com/kyren223/eko/internal/packet"
|
||||
"github.com/kyren223/eko/internal/server/ctxkeys"
|
||||
"github.com/kyren223/eko/internal/server/session"
|
||||
"github.com/kyren223/eko/pkg/assert"
|
||||
"github.com/kyren223/eko/pkg/snowflake"
|
||||
@@ -1626,7 +1625,7 @@ func Authenticate(ctx context.Context, sess *session.Session, request *packet.Au
|
||||
|
||||
// NOTE: as per the protocol, this must be the first message after auth
|
||||
payload := &packet.UsersInfo{Users: []data.User{user}}
|
||||
ok := sess.Write(ctx, WrapPayload(payload))
|
||||
ok := sess.Write(ctx, payload)
|
||||
if !ok {
|
||||
// Timeout, send at least this payload, client can request the rest
|
||||
return payload
|
||||
@@ -1657,8 +1656,8 @@ func sendInitialAuthPackets(ctx context.Context, sess *session.Session) bool {
|
||||
success = false
|
||||
continue
|
||||
}
|
||||
slog.InfoContext(ctx, "sending initial auth payload", ctxkeys.Payload.String(), payload, ctxkeys.PayloadType.String(), payload.Type())
|
||||
ok := sess.Write(ctx, WrapPayload(payload))
|
||||
slog.InfoContext(ctx, "sending initial auth payload", "payload", payload, "payload_type", payload.Type())
|
||||
ok := sess.Write(ctx, payload)
|
||||
if !ok {
|
||||
success = false
|
||||
continue
|
||||
|
||||
@@ -79,7 +79,7 @@ func NetworkPropagateWithFilter(
|
||||
context, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
go func() {
|
||||
defer cancel()
|
||||
if ok := session.Write(context, WrapPayload(payload)); !ok {
|
||||
if ok := session.Write(context, payload); !ok {
|
||||
log.Println(sess.Addr(), "propagation to", session.Addr(), "failed")
|
||||
}
|
||||
}()
|
||||
@@ -121,7 +121,7 @@ func UserPropagate(
|
||||
context, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
go func() {
|
||||
defer cancel()
|
||||
if ok := session.Write(context, WrapPayload(payload)); !ok {
|
||||
if ok := session.Write(context, payload); !ok {
|
||||
log.Println(sess.Addr(), "propagation to", session.Addr(), "failed")
|
||||
}
|
||||
}()
|
||||
@@ -189,7 +189,3 @@ func getNotifications(ctx context.Context, userId snowflake.ID) (packet.Notifica
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func WrapPayload(payload packet.Payload) packet.Packet {
|
||||
return packet.NewPacket(packet.NewMsgPackEncoder(payload))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user