Example #1
0
        async Task <Guid> subscribeToEventWithUrlAsync(string url, ParticleEventHandler handler, string eventNamePrefix)
        {
            var guid   = Guid.NewGuid();
            var source = new EventSource(url, ParticleCloud.AccessToken.Token, eventNamePrefix);

            source.AddEventListener(guid.ToString(), handler);

            await Task.Factory.StartNew(() => source.StartHandlingEvents().ConfigureAwait(false), TaskCreationOptions.LongRunning);

            ParticleCloud.SharedInstance.SubscibedEvents.Add(guid, source);
            return(guid);
        }