public Response Subscribe(Action<object> userCallback, Action<object> connectCallback, Action<object> errorCallback)
        {

            if (eventFilters.Count == 0)
            {
                throw new Exception("Event filters are undefined");
            }
            if (userCallback != null) notificationAction = userCallback;
            if (connectCallback != null) connectionAction = connectCallback;
            if (errorCallback != null) errorAction = errorCallback;
            try
            {
                var jsonData = GetFullEventsFilter();
                Request request = new Request(SubscriptionEndPoint, jsonData);
                Response response = _platform.Post(request);
                _subscription = JsonConvert.DeserializeObject<Subscription>(response.GetBody());
                if (_subscription.DeliveryMode.Encryption)
                {
                    PubNubServiceImplementation("", _subscription.DeliveryMode.SubscriberKey, _subscription.DeliveryMode.SecretKey, _subscription.DeliveryMode.EncryptionKey, false);
                }
                else
                {
                    PubNubServiceImplementation("", _subscription.DeliveryMode.SubscriberKey);
                }
                Subscribe(_subscription.DeliveryMode.Address, "", NotificationReturnMessage,  SubscribeConnectStatusMessage,  ErrorMessage);
                subscribed = true;
                SetTimeout();
                return response;
            }
            catch(Exception e)
            {
                Unsubscribe();
                throw e;
            }
            
        }
        public void Unsubscribe()
        {
            ClearTimeout();
            if(_pubnub != null)Unsubscribe(_subscription.DeliveryMode.Address, "", NotificationReturnMessage, SubscribeConnectStatusMessage, DisconnectMessage, ErrorMessage);
            _subscription = new Subscription();
            ClearEvents();
            subscribed = false;

        }
 public void UpdateSubscription(Subscription subscription)
 {
     ClearTimeout();
     _subscription = subscription;
     subscribed = true;
     SetTimeout();
 }