better handling of steam disconnect
This commit is contained in:
@@ -137,6 +137,10 @@ func (d *DemoMatchLoader) getRandomCM() *netutil.PortAddr {
|
||||
}
|
||||
|
||||
func (d *DemoMatchLoader) connectToSteam() error {
|
||||
if d.client.Connected() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if d.cmList != nil {
|
||||
err := d.client.ConnectTo(d.getRandomCM())
|
||||
if err != nil {
|
||||
@@ -221,8 +225,8 @@ func (d DemoMatchLoader) LoadDemo(demo *Demo) error {
|
||||
|
||||
func (d DemoMatchLoader) connectLoop() {
|
||||
for d.connectToSteam() != nil {
|
||||
log.Infof("Retrying connecting to steam")
|
||||
time.Sleep(time.Second)
|
||||
log.Infof("[DL] Retrying connecting to steam...")
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,10 +271,7 @@ func (d *DemoMatchLoader) steamEventHandler() {
|
||||
}
|
||||
case *steam.DisconnectedEvent:
|
||||
log.Warningf("Steam disconnected, trying to reconnect...")
|
||||
_, err := d.client.Connect()
|
||||
if err != nil {
|
||||
log.Errorf("[DL] Unable to reconnect to steam: %v", err)
|
||||
}
|
||||
go d.connectLoop()
|
||||
case *steam.LoginKeyEvent:
|
||||
log.Debug("Got login_key!")
|
||||
err := ioutil.WriteFile(d.loginKey, []byte(e.LoginKey), os.ModePerm)
|
||||
|
Reference in New Issue
Block a user