public void HandleCallback(CallbackMsg msg) { if (msg.IsType <SteamUser.LoginKeyCallback>()) { GetClient().Friends.SetPersonaState(EPersonaState.Online); Friend.Me = new Friend(GetClient().User.GetSteamID()); Friend.Me.Name = "me"; SteamAlerts.ShowToast("Connected to Steam"); } else if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; if (callback.Result == EResult.OK) { EnableAutoReconnect(); } else { DisableAutoReconnect(); } } else if (msg.IsType <SteamFriends.FriendMsgCallback>()) { SteamFriends.FriendMsgCallback callback = (SteamFriends.FriendMsgCallback)msg; if (callback.EntryType == EChatEntryType.ChatMsg) { Friend friend = Friend.GetFriendBySteamId(callback.Sender.ToString()); if (friend != activeChat) { Intent intent = new Intent(SteamAlerts.GetContext(), typeof(Chat)); intent.SetAction("chat_notification_" + DateTime.Now.Ticks); intent.PutExtra("steam_id", friend.SteamId.ToString()); SteamAlerts.Notification("Message from " + friend.Name, friend.Name + ": " + callback.Message, callback.Message, intent, "steam_id", friend.SteamId.ToString()); SteamAlerts.PlaySound(); SteamAlerts.Vibrate(400); } } } else if (msg.IsType <SteamClient.ConnectCallback>()) { SteamAlerts.Notification("Steam Droid", "Connected to Steam", "Connected to Steam", new Intent(SteamAlerts.GetContext(), typeof(Main)), null, null); } else if (msg.IsType <SteamClient.DisconnectCallback>()) { SteamAlerts.Notification("Steam Droid", "Disconnected from Steam", "Connected to Steam", new Intent(SteamAlerts.GetContext(), typeof(Main)), null, null); SteamAlerts.ShowToast("Disconnected from Steam"); } }
public void HandleCallback(CallbackMsg msg) { if (msg.IsType <SteamClient.ConnectCallback>()) { Logger.Get().Log("[Callback] Connected"); } else if (msg.IsType <SteamClient.DisconnectCallback>()) { Logger.Get().Log("[Callback] Disconnected"); IsAuthorized = false; Send(Protocol.Server.LoggedOut); } else if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; Logger.Get().Log("[Callback] Logon: " + callback.Result + "/" + callback.ExtendedResult); if (callback.Result == EResult.AccountLogonDenied || callback.Result == EResult.InvalidLoginAuthCode) { Send(Protocol.Server.AuthRequest); IsAuthorized = true; } if (callback.Result == EResult.OK) { IsAuthorized = true; } } else if (msg.IsType <SteamUser.LoginKeyCallback>()) { Logger.Get().Log("[Callback] Logged in, setting persona state to online"); steam.Friends.SetPersonaState(SteamKit2.EPersonaState.Online); Send(Protocol.Server.LoggedIn); } else if (msg.IsType <SteamFriends.FriendMsgCallback>()) { SteamFriends.FriendMsgCallback chat = (SteamFriends.FriendMsgCallback)msg; if (chat.EntryType == EChatEntryType.ChatMsg) { Send(Protocol.Server.ChatReceived, chat.Sender.ToString(), chat.Message); } } else if (msg.IsType <SteamFriends.PersonaStateCallback>()) { SteamFriends.PersonaStateCallback friend = (SteamFriends.PersonaStateCallback)msg; Send(Protocol.Server.FriendStateChanged, friend.FriendID.ToString(), friend.State.ToString(), friend.GameName); } }
/// <summary> /// Updates the Steam client and passes any pending callbacks /// </summary> public void Update() { while (true) { CallbackMsg msg = client.WaitForCallback(true); if (msg == null) { return; } client.FreeLastCallback(); if (msg.IsType <SteamClient.ConnectCallback>()) { user.LogOn(new SteamUser.LogOnDetails() { Username = username, Password = password, AuthCode = authcode }); } if (msg.IsType <SteamClient.DisconnectCallback>()) { loggedIn = false; } if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; if (callback.Result == EResult.OK) { this.loggedIn = true; this.authcode = null; } Friends.SetPersonaState(EPersonaState.Online); } Push(msg); } }
public void HandleCallback(CallbackMsg msg) { if (msg.IsType <SteamClient.ConnectCallback>()) { int retryCount = SteamService.GetClient().GetRetryCount(); String retries = (retryCount > 0) ? " (retry " + retryCount + ")" : ""; SteamAlerts.ShowProgressDialog("Connecting", "Logging in..." + retries, this); } else if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; if (callback.Result == EResult.AccountLogonDenied) { RequestAuthKey(); } else if (callback.Result == EResult.InvalidLoginAuthCode) { InvalidAuthKey(); } else if (callback.Result == EResult.InvalidPassword) { SteamAlerts.ShowAlertDialog("Invalid credentials", "Invalid username or password", this); } else if (callback.Result == EResult.AlreadyLoggedInElsewhere) { SteamAlerts.ShowAlertDialog("Already logged in", "This Steam account is already logged in elsewhere", this); } } else if (msg.IsType <SteamUser.LoggedOffCallback>()) { SteamUser.LoggedOffCallback callback = (SteamUser.LoggedOffCallback)msg; if (callback.Result == EResult.InvalidProtocolVer) { SteamAlerts.ShowAlertDialog("Error", "Invalid protocol version", this); } } UpdateButtons(); }
/// <summary> /// Processes the callbacks received from the callback thread /// </summary> /// <param name='msg'> /// Message. /// </param> public void ProcessCallback(CallbackMsg msg) { if (msg.IsType <SteamClient.ConnectCallback>()) { user.LogOn(new SteamUser.LogOnDetails() { Username = username, Password = password, AuthCode = authcode }); /* * timeout = TimeoutHandler.Start(10000, () => * { * Disconnect(); * * if (retry < 2) * { * Connect(); * * retry++; * } * else * { * retry = 0; * } * * return null; * });*/ } if (msg.IsType <SteamClient.DisconnectCallback>() || msg.IsType <SteamUser.LoggedOffCallback>()) { loggedIn = false; } if (msg.IsType <SteamUser.LogOnCallback>()) { SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg; if (callback.Result == EResult.OK) { loggedIn = true; authcode = null; retry = 0; /* * if (timeout != null) * { * timeout.Cancel(true); * }*/ /* * Friends.SetPersonaState(EPersonaState.Online); * * Friend.Me = new Friend(User.GetSteamID()); * Friend.Me.Name = "me"; * * SteamAlerts.ShowToast("Connected to Steam"); * SteamAlerts.Notification("SteamDroid", "Connected to Steam", "Connected to Steam", new Android.Content.Intent(SteamAlerts.GetContext(), typeof(App.Main)), null, null); */ } } if (msg.IsType <SteamUser.LoginKeyCallback>()) { Friends.SetPersonaState(EPersonaState.Online); Friend.Me = new Friend(User.GetSteamID()); Friend.Me.Name = "me"; SteamAlerts.ShowToast("Connected to Steam"); SteamAlerts.Notification("SteamDroid", "Connected to Steam", "Connected to Steam", new Android.Content.Intent(SteamAlerts.GetContext(), typeof(App.Main)), null, null); } Push(msg); }