void Client_WarcraftProfileReceived(object sender, WarcraftProfileEventArgs e) { if (__warcraftProfileReceived != null) { __warcraftProfileReceived.Call(_host.ClientHost, ConvObj(e)); } }
private void HandleProfile(ParseData pd) { DataReader dr = new DataReader(pd.Data); int cookie = dr.ReadInt32(); if (!m_warcraftProfileRequests.ContainsKey(cookie)) { Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie)); return; } WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie]; byte success = dr.ReadByte(); if (success != 0) { m_warcraftProfileRequests.Remove(cookie); ProfileLookupFailedEventArgs profileFailed = new ProfileLookupFailedEventArgs(args.Username, args.Product) { EventData = pd }; OnProfileLookupFailed(profileFailed); return; } string desc = dr.ReadCString(); string location = dr.ReadCString(); string tag = dr.ReadDwordString(0); WarcraftProfile profile = new WarcraftProfile(desc, location, tag); args.Profile = profile; if (!string.IsNullOrEmpty(tag)) { BncsPacket pck = new BncsPacket((byte)BncsPacketId.ClanMemberInformation); pck.InsertInt32(cookie); pck.InsertDwordString(tag, 0); pck.InsertCString(args.Username); Send(pck); } else { BncsPacket pck = new BncsPacket((byte)BncsPacketId.WarcraftGeneral); pck.InsertByte((byte)WarcraftCommands.UserInfoRequest); pck.InsertInt32(cookie); pck.InsertCString(args.Username); pck.InsertDwordString(args.Product.ProductCode); Send(pck); } BattleNetClientResources.IncomingBufferPool.FreeBuffer(pd.Data); }
private void HandleWarcraftClanInfoRequest(DataReader dr) { int cookie = dr.ReadInt32(); if (!m_warcraftProfileRequests.ContainsKey(cookie)) { Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie)); return; } WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie]; int recordCount = dr.ReadByte(); WarcraftClanLadderRecord[] ladderRecords = new WarcraftClanLadderRecord[recordCount]; for (int i = 0; i < recordCount; i++) { WarcraftClanLadderType ladderType = (WarcraftClanLadderType)dr.ReadInt32(); int wins = dr.ReadInt16(); int losses = dr.ReadInt16(); int level = dr.ReadByte(); int hrs = dr.ReadByte(); int xp = dr.ReadInt16(); int rank = dr.ReadInt32(); WarcraftClanLadderRecord record = new WarcraftClanLadderRecord(ladderType, wins, losses, level, hrs, xp, rank); ladderRecords[i] = record; } int raceRecordCount = dr.ReadByte(); Warcraft3IconRace[] raceOrder = new Warcraft3IconRace[] { Warcraft3IconRace.Random, Warcraft3IconRace.Human, Warcraft3IconRace.Orc, Warcraft3IconRace.Undead, Warcraft3IconRace.NightElf, Warcraft3IconRace.Tournament }; WarcraftRaceRecord[] raceRecords = new WarcraftRaceRecord[raceRecordCount]; for (int i = 0; i < raceRecordCount; i++) { int wins = dr.ReadInt16(); int losses = dr.ReadInt16(); WarcraftRaceRecord record = new WarcraftRaceRecord(raceOrder[i], wins, losses); raceRecords[i] = record; } args.Clan.SetStats(ladderRecords, raceRecords); BncsPacket pck = new BncsPacket((byte)BncsPacketId.WarcraftGeneral); pck.InsertByte((byte)WarcraftCommands.UserInfoRequest); pck.InsertInt32(cookie); pck.InsertCString(args.Username); pck.InsertDwordString(args.Product.ProductCode); Send(pck); }
/// <summary> /// Requests a Warcraft 3 profile. /// </summary> /// <param name="username">The name of the user to request.</param> /// <param name="getFrozenThroneProfile"><see langword="true" /> to get the Frozen Throne profile; /// <see langword="false" /> to get the Reign of Chaos profile.</param> public virtual void RequestWarcraft3Profile(string username, bool getFrozenThroneProfile) { Product pr = getFrozenThroneProfile ? Product.Warcraft3Expansion : Product.Warcraft3Retail; int cookie = Interlocked.Increment(ref m_curProfileCookie); BncsPacket pck = new BncsPacket((byte)BncsPacketId.Profile); pck.InsertInt32(cookie); pck.InsertCString(username); WarcraftProfileEventArgs args = new WarcraftProfileEventArgs(username, pr); m_warcraftProfileRequests.Add(cookie, args); Send(pck); }
private void WarcraftProfileReceived(object sender, WarcraftProfileEventArgs e) { ThreadStart ts = delegate { WarcraftProfileDisplayDocument doc = new WarcraftProfileDisplayDocument(e); doc.ShowDialog(this); }; if (InvokeRequired) { BeginInvoke(ts); } else { ts(); } }
private void HandleClanMemberInformation(ParseData pd) { DataReader dr = new DataReader(pd.Data); int cookie = dr.ReadInt32(); if (!m_warcraftProfileRequests.ContainsKey(cookie)) { Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie)); return; } WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie]; byte success = dr.ReadByte(); if (success != 0) { m_warcraftProfileRequests.Remove(cookie); ProfileLookupFailedEventArgs profileFailed = new ProfileLookupFailedEventArgs(args.Username, args.Product) { EventData = pd }; OnProfileLookupFailed(profileFailed); return; } string clanName = dr.ReadCString(); ClanRank rank = (ClanRank)dr.ReadByte(); DateTime joined = DateTime.FromFileTime(dr.ReadInt64()); args.Clan = new ClanProfile(clanName, rank, joined); BncsPacket pck = new BncsPacket((byte)BncsPacketId.WarcraftGeneral); pck.InsertByte((byte)WarcraftCommands.ClanInfoRequest); pck.InsertInt32(cookie); pck.InsertDwordString(args.Profile.ClanTag, 0); pck.InsertDwordString(args.Product.ProductCode); Send(pck); BattleNetClientResources.IncomingBufferPool.FreeBuffer(pd.Data); }
public WarcraftProfileDisplayDocument(WarcraftProfileEventArgs args) : this(args.Profile) { this.name.Text = args.Username; this.homepage.Text = args.Profile.Location; if (args.Clan != null) { foreach (var rec in args.Clan.LadderRecords) { this.clanStats.Controls.Add(new RecordDisplay(rec)); } this.clanName.Text = string.Format(CultureInfo.CurrentUICulture, "{0} ({1})", args.Clan.ClanName, args.Profile.ClanTag); this.clanRecords.BindToStats(args.Clan.RaceRecords); this.clanRank.Text = args.Clan.Rank.ToString(); this.personalStats.IsExpansion = (args.Product == Product.Warcraft3Expansion); this.clanRecords.IsExpansion = personalStats.IsExpansion; } else { clanName.Text = ""; } }
/// <summary> /// Raises the WarcraftProfileReceived event. /// </summary> /// <remarks> /// <para>Only high-priority events are invoked immediately; others are deferred. For more information, see <see>WarcraftProfileReceived</see>.</para> /// </remarks> /// <param name="e">The event arguments.</param> /// <seealso cref="WarcraftProfileReceived" /> protected virtual void OnWarcraftProfileReceived(WarcraftProfileEventArgs e) { foreach (WarcraftProfileEventHandler eh in __WarcraftProfileReceived[Priority.High]) { try { eh(this, e); } catch (Exception ex) { ReportException( ex, new KeyValuePair <string, object>("delegate", eh), new KeyValuePair <string, object>("Event", "WarcraftProfileReceived"), new KeyValuePair <string, object>("param: priority", Priority.High), new KeyValuePair <string, object>("param: this", this), new KeyValuePair <string, object>("param: e", e) ); } } ThreadPool.QueueUserWorkItem((WaitCallback) delegate { foreach (WarcraftProfileEventHandler eh in __WarcraftProfileReceived[Priority.Normal]) { try { eh(this, e); } catch (Exception ex) { ReportException( ex, new KeyValuePair <string, object>("delegate", eh), new KeyValuePair <string, object>("Event", "WarcraftProfileReceived"), new KeyValuePair <string, object>("param: priority", Priority.Normal), new KeyValuePair <string, object>("param: this", this), new KeyValuePair <string, object>("param: e", e) ); } } ThreadPool.QueueUserWorkItem((WaitCallback) delegate { foreach (WarcraftProfileEventHandler eh in __WarcraftProfileReceived[Priority.Low]) { try { eh(this, e); } catch (Exception ex) { ReportException( ex, new KeyValuePair <string, object>("delegate", eh), new KeyValuePair <string, object>("Event", "WarcraftProfileReceived"), new KeyValuePair <string, object>("param: priority", Priority.Low), new KeyValuePair <string, object>("param: this", this), new KeyValuePair <string, object>("param: e", e) ); } } FreeArgumentResources(e as BaseEventArgs); }); }); }
private void HandleWarcraftUserInfoRequest(ParseData data, DataReader dr) { int cookie = dr.ReadInt32(); if (!m_warcraftProfileRequests.ContainsKey(cookie)) { Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie)); return; } WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie]; string iconID = dr.ReadDwordString(0); args.Profile.IconID = iconID; int recordCount = dr.ReadByte(); WarcraftLadderRecord[] ladderRecords = new WarcraftLadderRecord[recordCount]; for (int i = 0; i < recordCount; i++) { WarcraftLadderType ladderType = (WarcraftLadderType)dr.ReadInt32(); int wins = dr.ReadInt16(); int losses = dr.ReadInt16(); int level = dr.ReadByte(); int hrs = dr.ReadByte(); int xp = dr.ReadInt16(); int rank = dr.ReadInt32(); WarcraftLadderRecord record = new WarcraftLadderRecord(ladderType, wins, losses, level, hrs, xp, rank); ladderRecords[i] = record; } int raceRecordCount = dr.ReadByte(); Warcraft3IconRace[] raceOrder = new Warcraft3IconRace[] { Warcraft3IconRace.Random, Warcraft3IconRace.Human, Warcraft3IconRace.Orc, Warcraft3IconRace.Undead, Warcraft3IconRace.NightElf, Warcraft3IconRace.Tournament }; WarcraftRaceRecord[] raceRecords = new WarcraftRaceRecord[raceRecordCount]; for (int i = 0; i < raceRecordCount; i++) { int wins = dr.ReadInt16(); int losses = dr.ReadInt16(); WarcraftRaceRecord record = new WarcraftRaceRecord(raceOrder[i], wins, losses); raceRecords[i] = record; } int teamRecordsCount = dr.ReadByte(); ArrangedTeamRecord[] teamRecords = new ArrangedTeamRecord[teamRecordsCount]; for (int i = 0; i < teamRecordsCount; i++) { ArrangedTeamType teamType = (ArrangedTeamType)dr.ReadInt32(); int wins = dr.ReadInt16(); int losses = dr.ReadInt16(); int level = dr.ReadByte(); int hrs = dr.ReadByte(); int xp = dr.ReadInt16(); int rank = dr.ReadInt32(); long ftLastGameplay = dr.ReadInt64(); DateTime lastGamePlayed = DateTime.FromFileTime(ftLastGameplay); int numPartners = dr.ReadByte(); string[] partnerList = new string[numPartners]; for (int p = 0; p < numPartners; p++) { partnerList[p] = dr.ReadCString(); } ArrangedTeamRecord record = new ArrangedTeamRecord(teamType, wins, losses, level, hrs, xp, rank, lastGamePlayed, partnerList); teamRecords[i] = record; } args.Profile.SetStats(ladderRecords, teamRecords, raceRecords); args.EventData = data; OnWarcraftProfileReceived(args); }
public void OnWarcraftProfileReceived(WarcraftProfileEventArgs e) { m_host.OnWarcraftProfileReceived(e); }