Skip to content

Commit 737654f

Browse files
committed
SendToTarget checks if event loop has finished
1 parent 0d5126f commit 737654f

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

registry.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ func SendToTarget(m Messagable, sessionID SessionID) error {
3939
session, err := lookupSession(sessionID)
4040
if err != nil {
4141
return err
42+
} else if session.toSend == nil {
43+
return fmt.Errorf("Not logged on")
4244
}
4345

4446
request := sendRequest{msg, make(chan error)}

session.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ func (s *session) run(msgIn chan fixIn, msgOut chan []byte, quit chan bool) {
511511
defer func() {
512512
close(s.messageOut)
513513
close(s.toSend)
514+
s.toSend = nil
514515
s.onDisconnect()
515516
}()
516517

0 commit comments

Comments
 (0)