public Task Delete(SessionCollection sessionCollection)
        {
            lock (Lck)
            {
                _storage.Remove(sessionCollection.SessionId);
            }

            return Task.FromResult(0);
        }
        public async Task<bool> Send(SessionCollection sessionCollection, string sharedKey)
        {
            using (var httpClient = new HttpClient())
            using (var request = this._httpMessageFormatter.GetRequestMessage(sessionCollection, sharedKey))
            {
                request.Method = HttpMethod.Post;
                request.RequestUri = CollectorUri;

                var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);

                return response.StatusCode == System.Net.HttpStatusCode.OK;
            }            
        }        
        private static byte[] ConvertToByteArray(SessionCollection sessionCollection)
        {
            var c = sessionCollection.Collection;

            var cbuilder = new Collection.Builder();

            cbuilder.DeviceId = c.DeviceId;

            cbuilder.ClientId = c.ClientId;

            cbuilder.Session = c.Session;

            cbuilder.SystemVersion = c.SystemVersion;

            cbuilder.ProductVersion = c.ProductVersion;

            cbuilder.System = c.System;

            cbuilder.ProductGitHash = c.ProductGitHash;

            foreach (var p in c.Payloads)
            {
                var pBuilder = new Payload.Builder();

                pBuilder.At = p.At;

                pBuilder.Event = p.Event;

                pBuilder.Nr = p.Nr;

                pBuilder.UserId = p.UserId;

                pBuilder.Ip = p.Ip;

                pBuilder.Parameters = p.Parameters;

                pBuilder.IsTesting = p.IsTesting;

                var payload = pBuilder.Build();

                cbuilder.AddPayloads(payload);
            }

            return cbuilder.Build().ToByteArray();
        }
        public HttpRequestMessage GetRequestMessage(SessionCollection sessionCollection, string sharedKey)
        {
            var result = new HttpRequestMessage();

            var content = ConvertToByteArray(sessionCollection);

            result.Content = new ByteArrayContent(content);

            var ts = DateTime.UtcNow.GetEpochUtc();

            result.Headers.Add("X-Hamustro-Time", ts.ToString());

            result.Headers.Add("X-Hamustro-Signature", CalculateCollectorSignature(ts, content, sharedKey));

            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/protobuf");

            return result;
        }
        public Task Add(SessionCollection sessionCollection)
        {
            lock (Lck)
            {
                if (_storage.ContainsKey(sessionCollection.SessionId))
                {
                    foreach (var ce in sessionCollection.Collection.Payloads)
                    {
                        _storage[sessionCollection.SessionId].Collection.Payloads.Add(ce);
                    }
                }
                else
                {
                    _storage.Add(sessionCollection.SessionId, sessionCollection);
                }
            }

            return Task.FromResult(0);
        }