void OnFriendMessage(SteamFriends.FriendMsgCallback cb) { Log.WriteLine("Msg from {0} {1} {2} \"{3}\"", cb.Sender, cb.EntryType, (int)cb.EntryType, cb.Message); var room_id = cb.Sender; var room = ChatRoom.Active.FindOrCreate(room_id); room.Messages.Add(new ChatMessage { Message = cb.Message, Sender = cb.Sender, Type = cb.EntryType }); // TODO: Thread safety var message_index = room.Messages.Count - 1; var b = new Core.Util.Buffer(); b.SetAlignment(4); b.WriteULong(cb.Sender); b.WriteULong(cb.Sender); b.Write((byte)cb.EntryType); b.Write((byte)(cb.FromLimitedAccount ? 1 : 0)); // b.Write((byte)0); b.Write((uint)message_index); Instance.PostCallback(Common.CallbackId(Common.CallbackType.ClientFriends, 5), b); }
void OnAccountLogonDenied(SteamUser.LoggedOnCallback cb) { logon_state = LogonState.LoggedOff; Log.WriteLine("OnAccountLogonDenied: {0}", cb.Result.ExtendedString()); switch (cb.Result) { case EResult.AccountLoginDeniedNeedTwoFactor: { Log.WriteLine("Needs twofactor code..."); logon_needs = LogonNeeds.TwoFactor; break; } case EResult.AccountLogonDenied: { Log.WriteLine("Needs steamguard code..."); logon_needs = LogonNeeds.SteamGuard; break; } } var b = new Core.Util.Buffer(); b.SetAlignment(4); b.Write((uint)cb.Result); b.WriteBool(false); Instance.PostCallback(102, b); }
public void StructTest(ref Core.Util.Buffer b) { b.Reset(); b.SetAlignment(4); b.WriteByte(0xAA); // 0 b.WriteUInt(0xBBCCDDEE); // 4 b.WriteUShort(0xFFAA); // 8 b.WriteByte(0xBB); // 10 b.WriteULong(0xCCDDEEFFAABBCCDD); // 12 }
public void OnClanState(SteamFriends.ClanStateCallback cb) { foreach (var e in cb.Events) { Core.Util.Buffer b = new Core.Util.Buffer(); b.SetAlignment(4); b.WriteULong(e.ID); b.WriteULong(cb.ClanID); // TODO: pad to 256 characters b.WriteString(e.Headline); b.WriteUInt(Platform.ToUnixTime(e.EventTime)); b.WriteULong(e.GameID); Instance.PostCallback(Common.CallbackId(Common.CallbackType.ClientFriends, 2), b); } // TODO: do something with announcements var clan = ClanGroup.Active.FindOrCreate(cb.ClanID); var name_changed = clan.Name != cb.ClanName; var avatar_changed = clan.AvatarHash != cb.AvatarHash; var acc_info_changed = clan.AccountFlags != cb.AccountFlags; // Might be completely unnecessary if (name_changed || avatar_changed || acc_info_changed) { Core.Util.Buffer b = new Core.Util.Buffer(); b.SetAlignment(4); b.WriteULong(cb.ClanID); b.WriteBool(name_changed); b.WriteBool(avatar_changed); b.WriteBool(acc_info_changed); Instance.PostCallback(Common.CallbackId(Common.CallbackType.ClientFriends, 19), b); } // Set all the new info that we have clan.Name = cb.ClanName; clan.AccountFlags = cb.AccountFlags; clan.AvatarHash = cb.AvatarHash; clan.ChatRoomPrivate = cb.ChatRoomPrivate; clan.MemberChattingCount = cb.MemberChattingCount; clan.MemberInGameCount = cb.MemberInGameCount; clan.MemberOnlineCount = cb.MemberOnlineCount; clan.MemberTotal = cb.MemberTotalCount; Log.WriteLine("OnClanState for {0} <{1}>", clan.Id, clan.Name); }
public void OnPersonaState(SteamFriends.PersonaStateCallback cb) { if (cb.FriendID.IsClanAccount) { Log.WriteLine("Found clan {0} <{1}>", cb.FriendID, steam_friends.GetClanName(cb.FriendID)); var c = ClanGroup.Active.FindOrCreate(cb.FriendID); c.Id = cb.FriendID; c.AvatarHash = steam_friends.GetClanAvatar(cb.FriendID); c.Name = steam_friends.GetClanName(cb.FriendID); } Core.Util.Buffer b = new Core.Util.Buffer(); b.SetAlignment(4); b.WriteULong(cb.FriendID); b.WriteUInt((uint)cb.StatusFlags); Instance.PostCallback(Common.CallbackId(Common.CallbackType.SteamFriends, 4), b); }