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