當前位置: 首頁>>代碼示例>>C#>>正文


C# Common.WaitForResponse方法代碼示例

本文整理匯總了C#中PubNubMessaging.Tests.Common.WaitForResponse方法的典型用法代碼示例。如果您正苦於以下問題:C# Common.WaitForResponse方法的具體用法?C# Common.WaitForResponse怎麽用?C# Common.WaitForResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PubNubMessaging.Tests.Common的用法示例。


在下文中一共展示了Common.WaitForResponse方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ItShouldReturnDetailedHistory

    public void ItShouldReturnDetailedHistory()
    {
      Pubnub pubnub = new Pubnub(
        "demo",
        "demo",
        "",
        "",
        false
        );
      string channel = "hello_world";
      string message = "Test Message";
      
      Common common = new Common();
      common.DeliveryStatus = false;
      common.Response = null;

      pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenDetailedHistoryIsRequested" ,"ItShouldReturnDetailedHistory");
      
      //publish a test message. 
      pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
      
      common.WaitForResponse();

      common.DeliveryStatus = false;
      common.Response = null;
      pubnub.DetailedHistory(channel, 1, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
      common.WaitForResponse();

      ParseResponse(common.Response, 0, 0, message);
    }
開發者ID:Evgeniy20,項目名稱:c-sharp,代碼行數:30,代碼來源:WhenDetailedHistoryIsRequested.cs

示例2: ItShouldReturnDetailedHistoryNoStore

        public void ItShouldReturnDetailedHistoryNoStore ()
        {
            Pubnub pubnub = new Pubnub (
                Common.PublishKey,
                Common.SubscribeKey,
                "",
                "",
                false
            );
            string channel = "hello_world_de1";
            string message = "Test Message No Store";

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenDetailedHistoryIsRequested", "ItShouldReturnDetailedHistory");

            //publish a test message. 
            pubnub.Publish (channel, message, false, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            common.DeliveryStatus = false;
            common.Response = null;
            //Thread.Sleep (2000);
            pubnub.DetailedHistory<string> (channel, 1, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
            common.WaitForResponse ();

            ParseResponseNoStore (common.Response.ToString(), message);
            pubnub.EndPendingRequests ();
        }
開發者ID:seeva92,項目名稱:c-sharp,代碼行數:32,代碼來源:WhenDetailedHistoryIsRequested.cs

示例3: SubscribePublishAndParse

        void SubscribePublishAndParse (string message, Pubnub pubnub, Common common, string channel)
        {
            Random r = new Random ();
            channel = "hello_world_sub" + r.Next (1000);

            pubnub.Subscribe<string> (channel, common.DisplayReturnMessage, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy); 
            Thread.Sleep (5000);

            pubnub.Publish (channel, message, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            if (common.Response != null) {
                object[] deserializedMessage = Common.Deserialize<object[]> (common.Response.ToString ());
                if (deserializedMessage != null) {
                    Assert.True (message.Equals (deserializedMessage [0].ToString ()));
                } else {
                    Assert.Fail ("Test not successful");
                }
            } else {
                Assert.Fail ("No response");
            }
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.Unsubscribe<string> (channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse (20);

            pubnub.EndPendingRequests ();

        }
開發者ID:hakangs,項目名稱:c-sharp,代碼行數:32,代碼來源:WhenSubscribedToAChannel2.cs

示例4: ThenShouldReturnUnsubscribedMessage

    public void ThenShouldReturnUnsubscribedMessage()
    {
      Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
      
      Common common = new Common();
      common.DeliveryStatus = false;
      common.Response = null;
      
      pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenUnsubscribedToAChannel", "ThenShouldReturnUnsubscribedMessage");
      
      string channel = "hello_world";

      pubnub.Subscribe<string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

      common.WaitForResponse();
      common.DeliveryStatus = false;
      common.Response = null;

      pubnub.Unsubscribe<string>(channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
      common.WaitForResponse();

      if (common.Response.ToString().Contains ("Unsubscribed from")) {
        Console.WriteLine("Response:" + common.Response);
		Assert.NotNull(common.Response);
      }
      else
      {
		Assert.Fail("ThenShouldReturnUnsubscribedMessage failed");
      }    
    }
開發者ID:Evgeniy20,項目名稱:c-sharp,代碼行數:30,代碼來源:WhenUnsubscribedToAChannel.cs

示例5: ThenItShouldReturnTimeStampSSL

        public void ThenItShouldReturnTimeStampSSL ()
        {
            Pubnub pubnub = new Pubnub (
                                Common.PublishKey,
                                Common.SubscribeKey,
                                "",
                                "",
                                true
                            );

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");
            ;

            string response = "";

            pubnub.Time (common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            IList<object> fields = common.Response as IList<object>;
            response = fields [0].ToString ();
            Console.WriteLine ("Response:" + response);
            Assert.AreNotEqual ("0", response);
            pubnub.EndPendingRequests ();
        }
開發者ID:hakangs,項目名稱:c-sharp,代碼行數:29,代碼來源:WhenGetRequestServerTime.cs

示例6: ThenNonExistentChannelShouldReturnNotSubscribed

        public void ThenNonExistentChannelShouldReturnNotSubscribed ()
        {
            Pubnub pubnub = new Pubnub (Common.PublishKey,
                          Common.SubscribeKey, "", "", false);

            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;
      
            pubnub.PubnubUnitTest = common.CreateUnitTestInstance ("WhenUnsubscribedToAChannel", "ThenNonExistentChannelShouldReturnNotSubscribed");
      
            string channel = "hello_world";
      
            pubnub.Unsubscribe<string> (channel, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy, common.DisplayReturnMessage);

            common.WaitForResponse ();

            Console.WriteLine ("Response:" + common.Response);
            if (common.Response.ToString ().ToLower ().Contains ("not subscribed")) {
                Assert.Pass ();
            } else {
                Assert.Fail ();
            }
            pubnub.EndPendingRequests ();
        }
開發者ID:seeva92,項目名稱:c-sharp,代碼行數:25,代碼來源:WhenUnsubscribedToAChannel.cs

示例7: ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2

 public void ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2()
 {
     Pubnub pubnub = new Pubnub(
         Common.PublishKey,
         Common.SubscribeKey,
                       "",
                       "enigma",
                       false
                   );
     string channel = "hello_world";
     object message = new PubnubDemoObject();
   
     Common common = new Common();
   
     pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2");
   
     common.DeliveryStatus = false;
     common.Response = null;
   
     pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessage);
     //wait till the response is received from the server
     common.WaitForResponse();
     if (common.Response != null)
         {
             IList<object> fields = common.Response as IList<object>;
             string sent = fields [1].ToString();
             string one = fields [0].ToString();
             Assert.AreEqual("Sent", sent);
             Assert.AreEqual("1", one);
         } else
         {
             Assert.Fail("Null response");
         }
 }
開發者ID:jugalkishor-sujal,項目名稱:c-sharp,代碼行數:34,代碼來源:WhenAMessageIsPublished.cs

示例8: NullMessage

        public void NullMessage()
        {
            Pubnub pubnub = new Pubnub(
                Common.PublishKey,
                Common.SubscribeKey,
                                "",
                                "",
                                false
                            );
            string channel = "hello_world";
            string message = null;

            Common common = new Common();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessage);
            //wait till the response is received from the server
            common.WaitForResponse();
            if (common.Response != null)
                {
                    IList<object> fields = common.Response as IList<object>;
                    string sent = fields [1].ToString();
                    string one = fields [0].ToString();
                    Assert.AreEqual("Sent", sent);
                    Assert.AreEqual("1", one);
                } else
                {
                    Assert.Fail("Null response");
                }
        }
開發者ID:jugalkishor-sujal,項目名稱:c-sharp,代碼行數:31,代碼來源:WhenAMessageIsPublished.cs

示例9: ThenItShouldReturnTimeStamp

        public void ThenItShouldReturnTimeStamp()
        {
            Pubnub pubnub = new Pubnub(
                "demo",
                "demo",
                "",
                "",
                false
            );

            Common common = new Common();
            common.DeliveryStatus = false;
            common.Response = null;

            pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenGetRequestServerTime", "ThenItShouldReturnTimeStamp");;
            
            string response = "";

            pubnub.Time(common.DisplayReturnMessage, common.DisplayReturnMessageDummy);
           
            common.WaitForResponse();

            IList<object> fields = common.Response as IList<object>;
            response = fields[0].ToString();
            Console.WriteLine("Response:" + response);
			Assert.False(("0").Equals(response));
        }
開發者ID:Evgeniy20,項目名稱:c-sharp,代碼行數:27,代碼來源:WhenGetRequestServerTime.cs

示例10: SendMultipleIntMessages

        public void SendMultipleIntMessages (int messageStart, int messageEnd, string channel, Pubnub pubnub)
        {
            Common common = new Common ();
            common.DeliveryStatus = false;
            common.Response = null;   

            for (int i = messageStart; i < messageEnd; i++) {
                common.DeliveryStatus = false;
                string msg = i.ToString ();
                pubnub.Publish (channel, msg, common.DisplayReturnMessage, common.DisplayReturnMessageDummy);

                common.WaitForResponse ();

                Console.WriteLine ("Message # " + i.ToString () + " published");
            }
        }
開發者ID:jugalkishor-sujal,項目名稱:c-sharp,代碼行數:16,代碼來源:WhenDetailedHistoryIsRequested.cs

示例11: IfHereNowIsCalledThenItShouldReturnInfo

        public void IfHereNowIsCalledThenItShouldReturnInfo()
        {
            Pubnub pubnub = new Pubnub(
               "demo",
               "demo",
               "",
               "",
               false
           );
            Common common = new Common();
            common.DeliveryStatus = false;
            common.Response = null;
            
            HereNow(pubnub, "IfHereNowIsCalledThenItShouldReturnInfo", common.DisplayReturnMessage);
            common.WaitForResponse();

            ParseResponse(common.Response);
        }
開發者ID:Evgeniy20,項目名稱:c-sharp,代碼行數:18,代碼來源:WhenAClientIsPresented.cs

示例12: ThenItShouldReturnReceivedMessage

        public void ThenItShouldReturnReceivedMessage()
        {
            Pubnub pubnub = new Pubnub(
              "demo",
              "demo",
              "",
              "",
              false
              );
            string channel = "hello_world";
            Common commonPresence = new Common();
            commonPresence.DeliveryStatus = false;
            commonPresence.Response = null;
            
            pubnub.PubnubUnitTest = commonPresence.CreateUnitTestInstance("WhenAClientIsPresented", "ThenPresenceShouldReturnReceivedMessage");
            
            pubnub.Presence(channel, commonPresence.DisplayReturnMessage, commonPresence.DisplayReturnMessageDummy, commonPresence.DisplayReturnMessageDummy);
            
            Common commonSubscribe = new Common();
            commonSubscribe.DeliveryStatus = false;
            commonSubscribe.Response = null;
            
            pubnub.Subscribe(channel, commonSubscribe.DisplayReturnMessage, commonSubscribe.DisplayReturnMessageDummy, commonPresence.DisplayReturnMessageDummy);
            //while (!commonSubscribe.DeliveryStatus) ;
            
            commonPresence.WaitForResponse(30);
            
            string response = "";
            if (commonPresence.Response == null) {
              Assert.Fail("Null response");
            }
            else
            {
              IList<object> responseFields = commonPresence.Response as IList<object>;
              foreach (object item in responseFields)
              {
                response = item.ToString();
                Console.WriteLine("Response:" + response);
                //Assert.IsNotEmpty(strResponse);
              }
			  Assert.True (("hello_world").Equals(responseFields[2]));
            }
        }
開發者ID:Evgeniy20,項目名稱:c-sharp,代碼行數:43,代碼來源:WhenAClientIsPresented.cs

示例13: SubscribePublishAndParse

        void SubscribePublishAndParse (string message, Pubnub pubnub, Common common, string channel)
        {
            pubnub.Subscribe<string> (channel, common.DisplayReturnMessage, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy); 
            Thread.Sleep (1500);

            pubnub.Publish (channel, message, common.DisplayReturnMessageDummy, common.DisplayReturnMessageDummy);

            common.WaitForResponse ();

            if (common.Response != null) {
                object[] deserializedMessage = Common.Deserialize<object[]> (common.Response.ToString ());
                if (deserializedMessage != null) {
                    Assert.True (message.Equals(deserializedMessage [0].ToString ()));
                } else {
                    Assert.Fail ("Test not successful");
                }
            } else {
                Assert.Fail ("No response");
            }
        }
開發者ID:jugalkishor-sujal,項目名稱:c-sharp,代碼行數:20,代碼來源:WhenSubscribedToAChannel2.cs

示例14: ThenLargeMessageShoudFailWithMessageTooLargeInfo

 public void ThenLargeMessageShoudFailWithMessageTooLargeInfo()
 {
     Pubnub pubnub = new Pubnub(
         Common.PublishKey,
         Common.SubscribeKey,
                         "",
                         "",
                         false
                     );
     string channel = "hello_world";
     string messageLarge2K = "This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. This is a large message test which will return an error message. ";
     
     Common common = new Common();
     
     pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenLargeMessageShoudFailWithMessageTooLargeInfo");
     
     common.DeliveryStatus = false;
     common.Response = null;
     
     pubnub.Publish(channel, messageLarge2K, common.DisplayReturnMessage, common.DisplayReturnMessage);
     //wait till the response is received from the server
     common.WaitForResponse();
     if (common.Response != null)
         {
             IList<object> fields = common.Response as IList<object>;
             string sent = fields [1].ToString();
             Assert.AreEqual("Message Too Large", sent);
         } else
         {
             Assert.Fail("Null response");
         }
 }
開發者ID:jugalkishor-sujal,項目名稱:c-sharp,代碼行數:32,代碼來源:WhenAMessageIsPublished.cs

示例15: Unsub

                private void Unsub(Common common, Pubnub pubnub, string channel)
                {
                    Common commonUnsubscribe = new Common();

                    common.DeliveryStatus = false;
                    common.Response = null;
                    pubnub.Unsubscribe<string>(channel, commonUnsubscribe.DisplayReturnMessageDummy, commonUnsubscribe.DisplayReturnMessageDummy, commonUnsubscribe.DisplayReturnMessage, common.DisplayReturnMessageDummy);

                    common.WaitForResponse();
                    string response = "";
                    if (common.Response == null)
                    {
                        Assert.Fail("Null response");
                    } else
                    {
                        object[] responseFields2 = Common.Deserialize<object[]>(common.Response.ToString());
                        int count = 0;
                        foreach (object item in responseFields2)
                        {
                            count++;
                            response = item.ToString();
                            UnityEngine.Debug.Log("Response:" + response);
                            if (count == 0){
                                Assert.True(item.ToString().Contains("leave"));
                            }
                        }
                                //Assert.True(responseFields2 [0].ToString().Contains("leave"));
                    }
                }
開發者ID:jugalkishor-sujal,項目名稱:c-sharp,代碼行數:29,代碼來源:WhenUnsubscribedToAChannel.cs


注:本文中的PubNubMessaging.Tests.Common.WaitForResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。