Checkpoint
This commit is contained in:
54 files changed
+6855
-526
No files matched your search
+18
-4
@@ -6,6 +6,7 @@ import (
|
||||
"net/textproto"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -34,6 +35,8 @@ type Player struct {
|
||||
addr string
|
||||
password string
|
||||
idleSubsystems []string
|
||||
artCache sync.Map // map of path to image
|
||||
artRequest chan *artRequest
|
||||
commands chan *Command
|
||||
errors chan error
|
||||
quit chan struct{}
|
||||
@@ -94,10 +97,11 @@ func New(addr, password string) (*Player, error) {
|
||||
return nil, err
|
||||
}
|
||||
p := &Player{
|
||||
addr: addr,
|
||||
commands: make(chan *Command, 16),
|
||||
errors: make(chan error, 1),
|
||||
quit: make(chan struct{}, 2),
|
||||
addr: addr,
|
||||
commands: make(chan *Command, 16),
|
||||
artRequest: make(chan *artRequest, 16),
|
||||
errors: make(chan error, 1),
|
||||
quit: make(chan struct{}, 2),
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
@@ -301,6 +305,15 @@ func (p *Player) run(events chan player.Event) {
|
||||
continue
|
||||
}
|
||||
|
||||
art, _, err := newConn(p.addr, p.password, "art", p.name)
|
||||
if err != nil {
|
||||
_ = idle.Close()
|
||||
_ = main.Close()
|
||||
log.WithError(err).Warn("connection failed; retrying")
|
||||
time.Sleep(time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
p.commands = make(chan *Command)
|
||||
p.errors = make(chan error)
|
||||
p.quit = make(chan struct{}, 2)
|
||||
@@ -308,6 +321,7 @@ func (p *Player) run(events chan player.Event) {
|
||||
events <- player.NewConnectedEvent(p)
|
||||
|
||||
go p.idleLoop(idle)
|
||||
go p.artLoop(art)
|
||||
p.mainLoop(main, events)
|
||||
|
||||
events <- player.NewDisconnectedEvent(p)
|
||||
|
||||
Reference in new issue
Block a user