Skip to content

Commit

Permalink
fix(#267): Maybe fixed empty message bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Nov 21, 2024
1 parent 7e42717 commit e6a0df7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/bs_rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c Client) Listen(ctx context.Context) error {
msgBuf = append(msgBuf, buf...)
}

if bytes.Contains(msgBuf, ENDSECTION) {
if bytes.Contains(msgBuf, ENDSECTION) && !bytes.Equal(msgBuf, ENDSECTION) {
msgParts := bytes.Split(msgBuf, ENDSECTION)

m, err := Unmarshall(
Expand Down
5 changes: 4 additions & 1 deletion pkg/bs_rpc/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import (

func Unmarshall(reg *msg.Registry, b []byte) (msg.Msg[msg.Body], error) {
genericMsg := msg.Msg[msg.Body]{}
_ = json.Unmarshal(b, &genericMsg)
err := json.Unmarshal(b, &genericMsg)
if err != nil {
return genericMsg, err
}

unMarshaller, err := reg.GetUnMarshaller(genericMsg.Type)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/pokete/msg/position/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func ReveiveUpdates(ctx context.Context) error {
return fmt.Errorf("message not positon update but: `%s`", u.GetType())
}

slog.InfoContext(ctx, fmt.Sprintf("%v", u.Position))

err = us.SetNewPositionToUser(conId, u.Position)
if err != nil {
return err
Expand Down

0 comments on commit e6a0df7

Please sign in to comment.