Exemplo n.º 1
0
        static public void test_time()
        {
            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
                );

            // Get PubNub Server Time
            objPubnub.Time(timedelegate);
        }
Exemplo n.º 2
0
        static public void test_uuid()
        {
            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
                );

            //Get UUID
            string uuid = objPubnub.UUID();

            Debug.WriteLine("Generated UUID - >  - " + uuid);
        }
Exemplo n.º 3
0
        static public void test_subscribe()
        {
            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
                );

            //define channel
            string channel = "hello-world";

            Dictionary <string, object> args = new Dictionary <string, object>();

            args = new Dictionary <string, object>();
            args.Add("channel", channel);
            args.Add("callback", new silverlight.Receiver());                // callback to get response
            objPubnub.Subscribe(args);
        }
Exemplo n.º 4
0
 static void subscribeChannels(pubnub pubnub)
 {
     foreach (string _channel in many_channels)
     {
         Thread t = new Thread(delegate()
         {
         Dictionary<String, Object> argsSub = new Dictionary<String, Object>(2);
         argsSub.Add("channel", _channel);
         argsSub.Add("callback", new Receiver());    // callback to get response
         // Listen for Messages (Subscribe)
         pubnub.Subscribe(argsSub);
         });
         t.Start();
         if (threads.ContainsKey(_channel))
             threads[_channel] = t;
         else
             threads.Add(_channel, t);
         try
         {
             Thread.Sleep(1000);
         }
         catch (ThreadAbortException e)
         {
             Debug.WriteLine(e.Message);
         }
     }
 }
Exemplo n.º 5
0
        static void UnitTestAll(pubnub pubnub)
        {
            status.Clear();
            threads.Clear();
            many_channels.Clear();
            if (runthroughs >= 2)
            {
                runthroughs = 0;
            }
            _pubnub = pubnub;

            if (!status.ContainsKey("sent"))
                status.Add("sent", 0);
            if (!status.ContainsKey("received"))
                status.Add("received", 0);
            if (!status.ContainsKey("connections"))
                status.Add("connections", 0);

            for (int i = 0; i < many_channels.Capacity; i++)
            {
                many_channels.Add("channel_" + i);
                channelConnected[many_channels[i]] = false;
                channelStatus[many_channels[i]] = status;
            }
            subscribeChannels(_pubnub);
        }
Exemplo n.º 6
0
        public static void test_uuid()
        {
            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
            );

            //Get UUID
            string uuid = objPubnub.UUID();
            Debug.WriteLine("Generated UUID - >  - " + uuid);
        }
Exemplo n.º 7
0
        public static void test_time()
        {
            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
            );

            // Get PubNub Server Time
            objPubnub.Time(timedelegate);
        }
Exemplo n.º 8
0
        public static void test_subscribe()
        {
            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
            );

            //define channel
            string channel = "hello-world";

            Dictionary<string, object> args = new Dictionary<string, object>();
            args = new Dictionary<string, object>();
            args.Add("channel", channel);
            args.Add("callback", new silverlight.Receiver());                // callback to get response
            objPubnub.Subscribe(args);
        }
Exemplo n.º 9
0
        public static void test_publish()
        {
            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
            );

            //define channel
            string channel = "hello-world";
            pubnub.ResponseCallback respCallback = delegate(object response)
            {
                List<object> messages = (List<object>)response;
                if (messages != null && messages.Count > 0)
                {
                    Debug.WriteLine("[" + messages[0] + " , " + messages[1] + "]");
                }
            };
            Dictionary<string, object> strArgs = new Dictionary<string, object>();
            string message = "Hello Silverlight";
            strArgs.Add("channel", channel);
            strArgs.Add("message", message);
            strArgs.Add("callback", respCallback);
            objPubnub.Publish(strArgs);
        }
Exemplo n.º 10
0
        public static void test_history()
        {
            pubnub.ResponseCallback histCallback = delegate(object response)
            {
                List<object> result = (List<object>)response;
                Debug.WriteLine("[History data]");
                foreach (object data in result)
                {
                    Debug.WriteLine(data);
                }
            };

            // Initialize pubnub state
            pubnub objPubnub = new pubnub(
                "demo",  // PUBLISH_KEY
                "demo",  // SUBSCRIBE_KEY
                "demo",  // SECRET_KEY
                "",      // CIPHER_KEY   (Cipher key is Optional)
                false    // SSL_ON?
            );

            //define channel
            string channel = "hello-world";

            // History
            Dictionary<string, object> argsHist = new Dictionary<string, object>();
            argsHist.Add("channel", channel);
            argsHist.Add("limit", 3.ToString());
            argsHist.Add("callback", histCallback);
            objPubnub.History(argsHist);
        }