コード例 #1
0
ファイル: PubSubBase.cs プロジェクト: uvatmvf/EasyWcfPubSub
 public void OnPublished(string channel, string publish)
 {
     if (!AsyncPublications)
     {
         Publish?.Invoke(channel, publish);
     }
     else if (AsyncPublications && UseSyncContext)
     {
         Task.Run(() =>
                  syncContext.Send(s =>
         {
             Publish?.Invoke(channel, publish);
         }, publish));
     }
     else
     {
         Task.Run(() => Publish?.Invoke(channel, publish));
     }
 }
コード例 #2
0
        private SmsAnalyzer()
        {
            this.ExternalApiSmsService = ExternalApiSmsService.Instance;
            this.SmsRenderModelsCache  = new List <SmsRenderModel>();
            this.ProcessedSmsHashes    = new List <string>();

            ExternalApiSmsService.Publish += () =>
            {
                this.SmsCache = ExternalApiSmsService.GetAllSms().OrderBy(s => s.Value.Timestamp);
                var unprocessedSms = SmsCache.Except(SmsCache.Where(s => ProcessedSmsHashes.Contains(s.Key)));

                var smsRenderModels = ProcessSms(unprocessedSms);
                if (smsRenderModels.Any())
                {
                    ProcessedSmsHashes.AddRange(smsRenderModels.Select(s => s.Sms.Hash));
                    SmsRenderModelsCache.AddRange(smsRenderModels);

                    Publish.Invoke();
                }
            };
        }
コード例 #3
0
        private void QueryExternalApi()
        {
            var mClient = new RestClient("https://mayhem-clockwork.herokuapp.com");

            var req = new RestRequest
            {
                Resource = "/",
                Method   = Method.GET
            };

            var resp = mClient.Execute(req);

            var content = resp.Content;

            var smsListJsonTokens = JArray.Parse(content);

            if (!smsListJsonTokens.Any())
            {
                return;
            }

            foreach (var smsJsonToken in smsListJsonTokens)
            {
                var sms = new SMS()
                {
                    FromNumber = (string)smsJsonToken.SelectToken("from"), ID = (string)smsJsonToken.SelectToken("id"), Text = (string)smsJsonToken.SelectToken("content"), Timestamp = (string)smsJsonToken.SelectToken("timestamp")
                };
                sms.Hash = ("" + sms.Timestamp + sms.Text + sms.FromNumber).ComputeHash(Hasher.eHashType.SHA1);
                if (!SmsCache.ContainsKey(sms.Hash))
                {
                    SmsCache.Add(sms.Hash, sms);
                }
            }

            Publish.Invoke();
        }
コード例 #4
0
ファイル: Hitbox.cs プロジェクト: nsthsn/ISOGNOME
 public void Hit()
 {
     Publish?.Invoke();
     //Debug.Log(Publish.);
 }
コード例 #5
0
 protected void OnPublish(EventArgs e)
 {
     Publish?.Invoke(this, e);
 }