Skip to content

Commit

Permalink
fix: Sync baseSocket.Self. (#69)
Browse files Browse the repository at this point in the history
Refs:
 - #68
  • Loading branch information
jfyne committed Aug 20, 2023
1 parent b83dc67 commit 5b4c05c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type BaseSocket struct {

data interface{}
dataMu sync.Mutex
selfMu sync.Mutex
}

// NewBaseSocket creates a new default socket.
Expand Down Expand Up @@ -128,6 +129,8 @@ func (s *BaseSocket) Connected() bool {
// Self sends an event to this socket itself. Will be handled in the
// handlers HandleSelf function.
func (s *BaseSocket) Self(ctx context.Context, event string, data interface{}) error {
s.selfMu.Lock()
defer s.selfMu.Unlock()
msg := Event{T: event, SelfData: data}
s.engine.self(ctx, s, msg)
return nil
Expand Down

0 comments on commit 5b4c05c

Please sign in to comment.