Open pashatag opened 1 year ago
func (c *Client) Launch(ctx context.Context, username, password string) { go func() { events := c.client.Events() for event := range events { switch event.(type) { case *steam.ConnectedEvent: c.client.Auth.LogOn(&steam.LogOnDetails{ Username: username, Password: password, }) case *steam.LoggedOnEvent: c.client.Social.SetPersonaState(steamlang.EPersonaState_Online) if c.onLoggin != nil { c.onLoggin() } case *steam.DisconnectedEvent: log.Println("disconnected") default: if c.onRaw != nil { c.onRaw(event) } } } }() steam.InitializeSteamDirectory() c.client.Connect() go func() { <-ctx.Done() c.client.Disconnect() }() }