public void DeleteSubscribeTest()
        {
            SubscriptionServiceImplementation sub = new SubscriptionServiceImplementation()
            {
                _platform = Platform
            };

            sub.AddEvent("/restapi/v1.0/account/~/extension/~/presence");
            sub.AddEvent("/restapi/v1.0/account/~/extension/~/message-store");
            var test = sub.Subscribe(null, null, null);

            Thread.Sleep(500);
            sub.Remove();
            Assert.IsFalse(sub.IsSubscribed());
            Thread.Sleep(500);
        }
        public void SubscribeTest()
        {
            SubscriptionServiceImplementation sub = new SubscriptionServiceImplementation()
            {
                _platform = Platform
            };

            sub.AddEvent("/restapi/v1.0/account/~/extension/~/presence");
            sub.AddEvent("/restapi/v1.0/account/~/extension/~/message-store");
            var subscribed = sub.Subscribe(null, null, null);

            Thread.Sleep(1000);
            Assert.IsNotNull(subscribed);
            Assert.AreEqual(true, subscribed.CheckStatus());
            Assert.IsTrue(sub.IsSubscribed());
            sub.Remove();
            Thread.Sleep(1000);
        }
        public void RenewSubscribeTest()
        {
            SubscriptionServiceImplementation sub = new SubscriptionServiceImplementation()
            {
                _platform = Platform
            };

            sub.AddEvent("/restapi/v1.0/account/~/extension/~/presence");
            sub.AddEvent("/restapi/v1.0/account/~/extension/~/message-store");
            var test = sub.Subscribe(null, null, null);

            Thread.Sleep(500);
            sub.ClearEvents();
            sub.SetEvents(new List <string>()
            {
                "/restapi/v1.0/account/~/extension/~/presence"
            });
            sub.Renew();
            Assert.IsTrue(sub.IsSubscribed());
            sub.Remove();
            Thread.Sleep(500);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var sdk      = new SDK(Config.AppKey, Config.AppSecret, Config.Server, "Test App", "1.0.0");
            var platform = sdk.Platform;

            platform.Login(Config.Username, Config.Extension, Config.Password, false);

            var sub = new SubscriptionServiceImplementation()
            {
                _platform = platform
            };

            sub.AddEvent("/restapi/v1.0/account/~/extension/~/presence");
            sub.AddEvent("/restapi/v1.0/account/~/extension/~/message-store");
            sub.Subscribe((message) => {
                Console.WriteLine("Event Received: " + message.ToString());
            }, null, null);

            var dict = new Dictionary <string, dynamic> {
                { "text", "hello world" },
                { "from", new Dictionary <string, string> {
                      { "phoneNumber", Config.Username }
                  } },
                { "to", new Dictionary <string, string>[] { new Dictionary <string, string> {
                                                                { "phoneNumber", Config.Receiver }
                                                            } } },
            };
            var request = new Request("/restapi/v1.0/account/~/extension/~/sms", JsonConvert.SerializeObject(dict));

            for (var i = 0; i < 10; i++)
            {
                platform.Post(request);
                Thread.Sleep(30000);
            }
            sub.Remove();

            Thread.Sleep(100000);
        }