private void OnPeerDataUpdated() { var peers = SignaledPeerData.Peers; ObservableCollection <ConversationViewModel> copyConversations = new ObservableCollection <ConversationViewModel>(Conversations); foreach (var contact in copyConversations) { if (peers.All(p => p.UserId != contact.UserId)) { Conversations.Remove(contact); } } foreach (var peer in peers) { var contact = Conversations.SingleOrDefault(s => s.UserId == peer.UserId); if (contact == null) { contact = _contactFactory(); contact.Name = peer.Name; contact.UserId = peer.UserId; contact.ProfileSource = new BitmapImage(new Uri(AvatarLink.EmbeddedLinkFor(peer.Avatar))); contact.OnCloseConversation += Contact_OnCloseConversation; contact.OnIsInCallMode += Contact_OnIsInCallMode; var sortList = Conversations.ToList(); sortList.Add(contact); sortList = sortList.OrderBy(s => s.Name).ToList(); Conversations.Insert(sortList.IndexOf(contact), contact); contact.Initialize(); } contact.IsOnline = peer.IsOnline; } UpdateSelection(); }
public void StartIncomingCall(RelayMessage message) { var foregroundIsVisible = false; var state = Hub.Instance.ForegroundClient.GetForegroundState(); if (state != null) { foregroundIsVisible = state.IsForegroundVisible; } if (!foregroundIsVisible) { var voipCallCoordinatorCc = VoipCallCoordinator.GetDefault(); VoipCall = voipCallCoordinatorCc.RequestNewIncomingCall(message.FromUserId, message.FromName, message.FromName, AvatarLink.CallCoordinatorUriFor(message.FromAvatar), "ChatterBox Universal", null, "", null, VoipPhoneCallMedia.Audio, new TimeSpan(0, 1, 20)); SubscribeToVoipCallEvents(); } }
public void OnPeerPresence(PeerUpdate peer) { ClientConfirmation(Confirmation.For(peer)); GetPeerList(new Message()); if (DateTimeOffset.UtcNow.Subtract(peer.SentDateTimeUtc).TotalSeconds < 10) { ToastNotificationService.ShowPresenceNotification( peer.PeerData.Name, AvatarLink.EmbeddedLinkFor(peer.PeerData.Avatar), peer.PeerData.IsOnline); } _foregroundChannel?.OnSignaledPeerDataUpdated(); }
public async void Run(IBackgroundTaskInstance taskInstance) { using (new BackgroundTaskDeferralWrapper(taskInstance.GetDeferral())) { try { var rawNotification = (RawNotification)taskInstance.TriggerDetails; var rawContent = rawNotification.Content; var serializedParameter = rawContent.Substring(rawContent.IndexOf(" ", StringComparison.CurrentCultureIgnoreCase) + 1); var type = typeof(RelayMessage); var message = (RelayMessage)JsonConvert.DeserializeObject(serializedParameter, type); if (message == null) { return; } var isTimeout = (DateTimeOffset.UtcNow - message.SentDateTimeUtc).TotalSeconds > 60; if (message.Tag == RelayMessageTags.Call) { if (isTimeout) { return; } ToastNotificationService.ShowInstantMessageNotification(message.FromName, message.FromUserId, AvatarLink.EmbeddedLinkFor(message.FromAvatar), $"Missed call at {message.SentDateTimeUtc.ToLocalTime()}."); } else if (message.Tag == RelayMessageTags.InstantMessage) { if (isTimeout || await SignaledInstantMessages.IsReceivedAsync(message.Id)) { return; } ToastNotificationService.ShowInstantMessageNotification(message.FromName, message.FromUserId, AvatarLink.EmbeddedLinkFor(message.FromAvatar), message.Payload); ReceivedPushNotifications.Add(message.Id); await SignaledInstantMessages.AddAsync(message); } } catch (Exception) { } } }
public IAsyncAction OnPeerPresenceAsync(PeerUpdate peer) { return(Task.Run(async() => { await ClientConfirmationAsync(Confirmation.For(peer)); await GetPeerListAsync(new Message()); if (DateTimeOffset.UtcNow.Subtract(peer.SentDateTimeUtc).TotalSeconds < 10) { ToastNotificationService.ShowPresenceNotification( peer.PeerData.Name, AvatarLink.EmbeddedLinkFor(peer.PeerData.Avatar), peer.PeerData.IsOnline); } _foregroundChannel?.OnSignaledPeerDataUpdatedAsync(); }).AsAsyncAction()); }
public async Task StartIncomingCallAsync(RelayMessage message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } // Check if the foreground UI is visible. // If it is then we don't trigger an incoming call because the call // can be answered from the UI and VoipCallCoordinator doesn't handle // this case. // As a workaround, when SetCallActive() is called when answered from the UI // we create an instance of an outgoing call. var foregroundIsVisible = false; var state = await Hub.Instance.ForegroundClient.GetForegroundStateAsync(); if (state != null) { foregroundIsVisible = state.IsForegroundVisible; } if (!foregroundIsVisible) { var voipCallCoordinator = VoipCallCoordinator.GetDefault(); _voipCall = voipCallCoordinator.RequestNewIncomingCall( message.FromUserId, message.FromName, message.FromName, AvatarLink.CallCoordinatorUriFor(message.FromAvatar), "ChatterBox", null, "", null, VoipPhoneCallMedia.Audio, new TimeSpan(0, 1, 20)); SubscribeToVoipCallEvents(); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { ToastNotificationLaunchArguments launchArg = null; if (args.Arguments != null && args.Arguments != String.Empty) { launchArg = ToastNotificationLaunchArguments.FromXmlString(args.Arguments); } if (args.PreviousExecutionState == ApplicationExecutionState.Running || args.PreviousExecutionState == ApplicationExecutionState.Suspended) { Resume(); ProcessLaunchArgument(launchArg); return; } await AvatarLink.ExpandAvatarsToLocal(); Container.RegisterInstance(CoreApplication.MainView.CoreWindow.Dispatcher); Container .RegisterType <ISignalingSocketChannel, SignalingSocketChannel>(new ContainerControlledLifetimeManager()) .RegisterType <ISignalingSocketOperation, SignalingSocketOperation>(new ContainerControlledLifetimeManager()) .RegisterType <ISignalingSocketService, SignalingSocketService>(new ContainerControlledLifetimeManager()) .RegisterType <SignalingClient>(new ContainerControlledLifetimeManager()) .RegisterType <IVideoRenderHelper, VideoRenderHelper>() .RegisterType <IForegroundChannel, ForegroundSignalingUpdateService>(new ContainerControlledLifetimeManager()) .RegisterType <IForegroundUpdateService, ForegroundSignalingUpdateService>(new ContainerControlledLifetimeManager()) .RegisterType <IClientChannel, ClientChannel>(new ContainerControlledLifetimeManager()) .RegisterType <IVoipCoordinator, VoipCoordinator>() .RegisterType <IHub, Voip.Hub>(new ContainerControlledLifetimeManager()) .RegisterType <VoipContext>(new ContainerControlledLifetimeManager()) .RegisterType <IVoipChannel, VoipChannel>(new ContainerControlledLifetimeManager()) .RegisterType <ISocketConnection, SocketConnection>(new ContainerControlledLifetimeManager()) .RegisterType <NtpService>(new ContainerControlledLifetimeManager()) .RegisterType <IMediaSettingsChannel, MediaSettingsChannel>() .RegisterType <SettingsViewModel>(new ContainerControlledLifetimeManager()) .RegisterInstance <MainViewModel>(Container.Resolve <MainViewModel>(), new ContainerControlledLifetimeManager()); Container.Resolve <SettingsViewModel>().OnQuitApp -= QuitApp; Container.Resolve <SettingsViewModel>().OnQuitApp += QuitApp; var rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored or there are launch arguments // indicating an alternate launch (e.g.: via toast or secondary tile), // navigate to the appropriate page, configuring the new page by passing required // information as a navigation parameter if (!rootFrame.Navigate(typeof(MainView), Container.Resolve <MainViewModel>())) { throw new Exception("Failed to create initial page"); } } // Avoid showing two dialogs in a short time or overlapping // otherwise an Access Denied exception is thrown. bool _isMessageForLockScreenShowed = false; var currentStatus = BackgroundExecutionManager.GetAccessStatus(); if (currentStatus == BackgroundAccessStatus.Unspecified || currentStatus == BackgroundAccessStatus.Denied) { _isMessageForLockScreenShowed = true; ShowMessageForMissingLockScreen(); } else { await RegisterForPush(); } Container.Resolve <IMediaSettingsChannel>().RequestAccessForMediaCaptureAsync().AsTask().ContinueWith((d) => { if (!d.Result && !_isMessageForLockScreenShowed) { ShowMessageForMissingAccess(); } }); ProcessLaunchArgument(launchArg); // Ensure the current window is active Window.Current.Activate(); }
public void Scan() { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); HtmlAgilityPack.HtmlDocument egov = new HtmlAgilityPack.HtmlDocument(); using (WebClient wc = new WebClient()) { doc.LoadHtml(wc.DownloadString("http://www.erepublik.com/en/citizen/profile/" + ID)); egov.LoadHtml(wc.DownloadString("http://www.egov4you.info/citizen/overview/" + ID)); } Citizen OldStatistics = (Citizen)this.MemberwiseClone(); OldStatistics.Medals = Medals.Clone(); // Needed!!! Name = doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'citizen_profile_header')]/h2").InnerText.Trim(); Strength = (int)Convert.ToDecimal(doc.DocumentNode.SelectSingleNode("//*[@class='citizen_military'][1]/h4").InnerText.Trim(), GameInfo.Culture); Rank = doc.DocumentNode.SelectSingleNode("//*[@class='citizen_military'][2]/h4/a").InnerHtml; RankPoints = Convert.ToDouble(doc.DocumentNode.SelectSingleNode("//div[@class='citizen_military'][2]/div/small[@style]").InnerText.Split('/')[0].RemoveNonDigits(), GameInfo.Culture); Level = Convert.ToInt16(doc.DocumentNode.SelectSingleNode("//strong[@class='citizen_level']").InnerText); Experience = Convert.ToInt32(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_experience']/div/p").InnerText.Split('/')[0].RemoveNonDigits()); NationalRank = Convert.ToInt16(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_second']/small[3]/strong").InnerText); Friends = Convert.ToInt16(doc.DocumentNode.SelectSingleNode("//div[@class='citizen_activity']/h4[@class='friends_title']").InnerText.Split('(')[1].Split(')')[0]); FirstFriendName = doc.DocumentNode.SelectSingleNode("//div[@class='citizen_activity']/ul/li/a").Attributes["title"].Value; Citizenship = doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_info']/a[3]").InnerText.Trim(); BirthDay = new CitizenBirthDay(Convert.ToDateTime(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_second']/p[2]").InnerText.Trim(), GameInfo.Culture)); #region Avatar AvatarLink = doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'citizen_profile_header')]/img").Attributes["style"].Value; AvatarLink = AvatarLink.Substring(AvatarLink.IndexOf('(') + 1); AvatarLink = AvatarLink.Substring(0, AvatarLink.Length - 2); AvatarLink = AvatarLink.Replace("_142x142", ""); #endregion #region Residence Residence = new CitizenResidence( doc.DocumentNode.SelectSingleNode("//div[@class='citizen_info']/a[1]").InnerText.Trim(), doc.DocumentNode.SelectSingleNode("//div[@class='citizen_info']/a[2]").InnerText.Trim()); #endregion #region PoliticalParty try { PoliticalParty = new CitizenGroup( doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][1]/div/span/a").InnerText.Trim(), Convert.ToInt32(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][1]/div/span/a").Attributes["href"].Value.Split('/')[3].Reverse().Split('-')[0].Reverse()), doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][1]/h3").InnerText.Trim(), -1); HtmlAgilityPack.HtmlDocument docParty = new HtmlAgilityPack.HtmlDocument(); docParty.LoadHtml(new WebClient().DownloadString("http://www.erepublik.com/en/party/" + PoliticalParty.ID)); PoliticalParty.Members = Convert.ToInt16(docParty.DocumentNode.SelectSingleNode("//div[@class='indent']/div[@class='infoholder']/p/span[2]").InnerText.Split(' ')[0]); if (PoliticalParty.Position == "Vice President") { PoliticalParty.Position = "Vice Party President"; } } catch { PoliticalParty = new CitizenGroup("N/A", -1, "N/A", -1); } #endregion #region MilitaryUnit try { MilitaryUnit = new CitizenGroup( doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][2]/div/a/span").InnerText.Trim(), Convert.ToInt32(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][2]/div/a").Attributes["href"].Value.Split('/')[4]), doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][2]/h3").InnerText.Trim(), -1); HtmlAgilityPack.HtmlDocument docMu = new HtmlAgilityPack.HtmlDocument(); docMu.LoadHtml(new WebClient().DownloadString("http://www.erepublik.com/en/main/group-list/members/" + MilitaryUnit.ID)); MilitaryUnit.Members = Convert.ToInt16(docMu.DocumentNode.SelectSingleNode("//div[@class='header_content']/h2/big").InnerText.Split(' ')[0]); } catch { MilitaryUnit = new CitizenGroup("N/A", -1, "N/A", -1); } #endregion #region Newspaper try { Newspaper = new CitizenGroup( doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][3]/div/a/span").InnerText.Trim(), Convert.ToInt32(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][3]/div/a").Attributes["href"].Value.Split('/')[3].Reverse().Split('-')[0].Reverse()), doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_activity']/div[@class='place'][3]/h3").InnerText.Trim(), -1); //HtmlAgilityPack.HtmlDocument docNews = new HtmlAgilityPack.HtmlDocument(); //docNews.LoadHtml(new WebClient().DownloadString("http://www.erepublik.com/en/newspaper/" + Newspaper.ID)); //Newspaper.Members = Convert.ToInt16(docNews.DocumentNode.SelectSingleNode("//div[@class='header_content']/h2/big").InnerText.Split(' ')[0]); } catch { Newspaper = new CitizenGroup("N/A", -1, "N/A", -1); } #endregion #region TruePatriotDamage try { TruePatriotDamage = new CitizenDamage( Convert.ToInt64(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_military'][3]/h4").InnerText.RemoveNonDigits()), doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_military'][3]/h4/img").Attributes["alt"].Value); } catch { TruePatriotDamage = new CitizenDamage(0, "None"); } #endregion #region TopCampaignDamage try { TopCampaignDamage = new CitizenDamage( Convert.ToInt64(doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_military'][4]/h4").InnerText.RemoveNonDigits()), doc.DocumentNode.SelectSingleNode(".//div[@class='citizen_military'][4]/h4/img").Attributes["alt"].Value); } catch { TopCampaignDamage = new CitizenDamage(0, "None"); } #endregion #region MonthlyDamage if (egov.DocumentNode.SelectSingleNode("//*[@id='eContainer']/section[4]/table/tr/td[2]/table[1]/tbody/tr/td") != null) { MonthlyDamage = Convert.ToInt64(egov.DocumentNode.SelectSingleNode("//*[@id='eContainer']/section[4]/table/tr/td[2]/table[1]/tbody/tr/td").InnerText.Trim().Replace(",", "")); } else { MonthlyDamage = 0; } #endregion #region BombsUsed try { BombsUsed = new CitizenBombsUsed( Convert.ToInt16(doc.DocumentNode.SelectSingleNode("//div[@class='citizen_mass_destruction']/strong[1]/b").InnerText), Convert.ToInt16(doc.DocumentNode.SelectSingleNode("//div[@class='citizen_mass_destruction']/strong[2]/b").InnerText), doc.DocumentNode.SelectSingleNode("//div[@class='citizen_mass_destruction']/em").ChildNodes[2].InnerText.Trim()); } catch { BombsUsed = new CitizenBombsUsed(0, 0); } #endregion #region Decorations //try //{ for (int i = 0; i < doc.DocumentNode.SelectNodes("//ul[@id='new_achievements']/li").Count; i++) { if (doc.DocumentNode.SelectSingleNode("//ul[@id='new_achievements']/li[" + (i + 1) + "]").Attributes["class"].Value != "unknown") { Array.Resize(ref decoration, Decoration.Length + 1); Decoration[i] = new Decoration( doc.DocumentNode.SelectSingleNode("//ul[@id='new_achievements']/li[" + (i + 1) + "]/img").Attributes["src"].Value, doc.DocumentNode.SelectSingleNode("//ul[@id='new_achievements']/li[" + (i + 1) + "]/div/span/p").InnerText.Trim()); if (doc.DocumentNode.SelectSingleNode("//ul[@id='new_achievements']/li[" + (i + 1) + "]/em") != null) { Decoration[i].Count = Convert.ToInt16(doc.DocumentNode.SelectSingleNode("//ul[@id='new_achievements']/li[" + (i + 1) + "]/em").InnerText); } //MessageBox.Show( // Decoration[i].ImageLink + Environment.NewLine + // Decoration[i].Text + Environment.NewLine + // Decoration[i].Count); } } //} //catch //{ //} #endregion #region Medals string[] medalCodeNames = new string[] { "Freedom Fighter", "hard worker", "congressman", "president", "media mogul", "battle hero", "campaign hero", "resistance hero", "super soldier", "society builder", "mercenary", "Top Fighter", "true patriot", }; for (int i = 0; i < medalCodeNames.Length; i++) { if (doc.DocumentNode.SelectSingleNode(".//ul[@id='achievment']/li[img[@alt='" + medalCodeNames[i] + "']]/div[@class='counter']") != null) { Medals.Medal[i] = Convert.ToInt16(doc.DocumentNode.SelectSingleNode(".//ul[@id='achievment']/li[img[@alt='" + medalCodeNames[i] + "']]/div[@class='counter']").InnerText); } } #endregion #region WorldRankings try { WorldRanking = new CitizenRanking( Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[1]/td[2]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[1]/td[3]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[1]/td[4]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[1]/td[5]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[1]/td[6]").InnerText.RemoveNonDigits())); } catch { WorldRanking = new CitizenRanking(0, 0, 0, 0, 0); } #endregion #region CountryRankings try { CountryRanking = new CitizenRanking( Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[2]/td[2]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[2]/td[3]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[2]/td[4]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[2]/td[5]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[2]/td[6]").InnerText.RemoveNonDigits())); } catch { CountryRanking = new CitizenRanking(0, 0, 0, 0, 0); } #endregion #region UnitRankings try { UnitRanking = new CitizenRanking( Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[3]/td[2]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[3]/td[3]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[3]/td[4]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[3]/td[5]").InnerText.RemoveNonDigits()), Convert.ToInt32(egov.DocumentNode.SelectSingleNode("//section[@id='eContainer']/section[4]/table/tr/td[1]/table[1]/tbody/tr/td/table/tbody/tr[3]/td[6]").InnerText.RemoveNonDigits())); } catch { UnitRanking = new CitizenRanking(0, 0, 0, 0, 0); } #endregion #region GuerillaScore GuerillaScore = new GuerillaScore( Convert.ToInt32(doc.DocumentNode.SelectSingleNode("//div[@class='guerilla_fights won']").InnerText), Convert.ToInt32(doc.DocumentNode.SelectSingleNode("//div[@class='guerilla_fights lost']").InnerText)); #endregion Influence = (long)(RankPoints - OldStatistics.RankPoints) * 10; //if (OldStatistics.BombsUsed.Small < BombsUsed.Small) // switch(Division) // { // case 1: // Influence += 75000 * (BombsUsed.Small - OldStatistics.BombsUsed.Small); // break; // case 2: // Influence += 375000 * (BombsUsed.Small - OldStatistics.BombsUsed.Small); // break; // case 3: // Influence += 750000 * (BombsUsed.Small - OldStatistics.BombsUsed.Small); // break; // case 4: // Influence += 1500000 * (BombsUsed.Small - OldStatistics.BombsUsed.Small); // break; // } //if (OldStatistics.BombsUsed.Big < BombsUsed.Big) // Influence += (BombsUsed.Big - OldStatistics.BombsUsed.Big) * 5000000; StrengthGained = Strength - OldStatistics.Strength; RankPointsGained = (int)(RankPoints - OldStatistics.RankPoints); ExperienceGained = Experience - OldStatistics.Experience; if (Rank != OldStatistics.Rank) { RankUp = OldStatistics.Rank + " → " + Rank; } else { RankUp = ""; } if (Level != OldStatistics.Level) { LevelUp = OldStatistics.Level + " → " + Level; } else { LevelUp = ""; } for (int i = 0; i < MedalsGained.Medal.Length; i++) { MedalsGained.Medal[i] = Medals.Medal[i] - OldStatistics.Medals.Medal[i]; } if (ID == 2972052) { Name = "Mlendea Horațiu"; BirthDay = new CitizenBirthDay(new DateTime(2011, 8, 21)); Residence = new CitizenResidence("Romania", "Crisana"); } }
public void ServerRelay(RelayMessage message) { ClientConfirmation(Confirmation.For(message)); SignaledRelayMessages.Add(message); var shownUserId = _foregroundChannel.GetShownUserId(); if (message.Tag == RelayMessageTags.InstantMessage && !SignaledRelayMessages.IsPushNotificationReceived(message.Id) && !(shownUserId != null && shownUserId.Equals(message.FromUserId)) && (DateTimeOffset.UtcNow.Subtract(message.SentDateTimeUtc).TotalMinutes < 10)) { ToastNotificationService.ShowInstantMessageNotification(message.FromName, message.FromUserId, AvatarLink.EmbeddedLinkFor(message.FromAvatar), message.Payload); } _foregroundChannel?.OnSignaledRelayMessagesUpdated(); // Handle Voip tags if (message.Tag == RelayMessageTags.VoipCall) { _voipChannel.OnIncomingCall(message); } else if (message.Tag == RelayMessageTags.VoipAnswer) { _voipChannel.OnOutgoingCallAccepted(message); } else if (message.Tag == RelayMessageTags.VoipReject) { _voipChannel.OnOutgoingCallRejected(message); } else if (message.Tag == RelayMessageTags.SdpOffer) { _voipChannel.OnSdpOffer(message); } else if (message.Tag == RelayMessageTags.SdpAnswer) { _voipChannel.OnSdpAnswer(message); } else if (message.Tag == RelayMessageTags.IceCandidate) { _voipChannel.OnIceCandidate(message); } else if (message.Tag == RelayMessageTags.VoipHangup) { _voipChannel.OnRemoteHangup(message); } }
public IAsyncAction ServerRelayAsync(RelayMessage message) { return(Task.Run(async() => { await ClientConfirmationAsync(Confirmation.For(message)); if (message.Tag == RelayMessageTags.InstantMessage) { await SignaledInstantMessages.AddAsync(message); } var shownUserId = await _foregroundChannel.GetShownUserIdAsync(); if (message.Tag == RelayMessageTags.InstantMessage && !ReceivedPushNotifications.IsReceived(message.Id) && !(shownUserId != null && shownUserId.Equals(message.FromUserId)) && (DateTimeOffset.UtcNow.Subtract(message.SentDateTimeUtc).TotalMinutes < 10)) { ToastNotificationService.ShowInstantMessageNotification(message.FromName, message.FromUserId, AvatarLink.EmbeddedLinkFor(message.FromAvatar), message.Payload); } _foregroundChannel?.OnSignaledRelayMessagesUpdatedAsync(); // Handle call tags if (message.Tag == RelayMessageTags.Call) { await _callChannel.OnIncomingCallAsync(message); } else if (message.Tag == RelayMessageTags.CallAnswer) { await _callChannel.OnOutgoingCallAcceptedAsync(message); } else if (message.Tag == RelayMessageTags.CallReject) { await _callChannel.OnOutgoingCallRejectedAsync(message); } else if (message.Tag == RelayMessageTags.SdpOffer) { await _callChannel.OnSdpOfferAsync(message); } else if (message.Tag == RelayMessageTags.SdpAnswer) { await _callChannel.OnSdpAnswerAsync(message); } else if (message.Tag == RelayMessageTags.IceCandidate) { await _callChannel.OnIceCandidateAsync(message); } else if (message.Tag == RelayMessageTags.CallHangup) { await _callChannel.OnRemoteHangupAsync(message); } }).AsAsyncAction()); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { ToastNotificationLaunchArguments launchArg = null; //TODO: Find out why e.Kind is ActivationKind.Launch even when app is lauched by clicking a toast notification //if ((e.Kind == ActivationKind.ToastNotification) && (!string.IsNullOrEmpty(e.Arguments))) if ((!string.IsNullOrEmpty(e.Arguments))) { launchArg = ToastNotificationLaunchArguments.FromXmlString(e.Arguments); } if (e.PreviousExecutionState == ApplicationExecutionState.Running) { ProcessLaunchArgument(launchArg); return; } if (e.PreviousExecutionState == ApplicationExecutionState.Suspended) { Resume(); ProcessLaunchArgument(launchArg); return; } await AvatarLink.ExpandAvatarsToLocal(); //Register IoC types if (!Container.IsRegistered <HubClient>()) { Container.RegisterInstance(CoreApplication.MainView.CoreWindow.Dispatcher); Container.RegisterType <TaskHelper>(new ContainerControlledLifetimeManager()); Container.RegisterType <HubClient>(new ContainerControlledLifetimeManager()); Container.RegisterInstance <IForegroundUpdateService>(Container.Resolve <HubClient>(), new ContainerControlledLifetimeManager()); Container.RegisterInstance <IForegroundChannel>(Container.Resolve <HubClient>(), new ContainerControlledLifetimeManager()); Container.RegisterInstance <ISignalingSocketChannel>(Container.Resolve <HubClient>(), new ContainerControlledLifetimeManager()); Container.RegisterInstance <IClientChannel>(Container.Resolve <HubClient>(), new ContainerControlledLifetimeManager()); Container.RegisterInstance <IVoipChannel>(Container.Resolve <HubClient>(), new ContainerControlledLifetimeManager()); Container.RegisterInstance <IMediaSettingsChannel>(Container.Resolve <HubClient>(), new ContainerControlledLifetimeManager()); Container.RegisterType <ISocketConnection, SocketConnection>(new ContainerControlledLifetimeManager()); Container.RegisterType <NtpService>(new ContainerControlledLifetimeManager()); Container.RegisterType <MainViewModel>(new ContainerControlledLifetimeManager()); Container.RegisterType <SettingsViewModel>(new ContainerControlledLifetimeManager()); } Container.Resolve <HubClient>().OnDisconnectedFromHub -= App_OnDisconnectedFromHub; Container.Resolve <HubClient>().OnDisconnectedFromHub += App_OnDisconnectedFromHub; Container.Resolve <SettingsViewModel>().OnQuitApp -= QuitApp; Container.Resolve <SettingsViewModel>().OnQuitApp += QuitApp; ConnectHubClient(); await RegisterForPush(Container.Resolve <TaskHelper>()); var signalingTask = await RegisterSignalingTask(Container.Resolve <TaskHelper>(), false); if (signalingTask == null) { var message = new MessageDialog("The signaling task is required."); await message.ShowAsync(); return; } await RegisterSessionConnectedTask(Container.Resolve <TaskHelper>()); var rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainView), Container.Resolve <MainViewModel>()); } ProcessLaunchArgument(launchArg); // Ensure the current window is active Window.Current.Activate(); }