本文整理汇总了C#中Pubnub.AddChannelsToChannelGroup方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.AddChannelsToChannelGroup方法的具体用法?C# Pubnub.AddChannelsToChannelGroup怎么用?C# Pubnub.AddChannelsToChannelGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.AddChannelsToChannelGroup方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThenAddChannelShouldReturnSuccess
public void ThenAddChannelShouldReturnSuccess()
{
currentUnitTestCase = "ThenAddChannelShouldReturnSuccess";
receivedChannelGroupMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenChannelGroupIsRequested";
unitTest.TestCaseName = "ThenAddChannelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
channelGroupManualEvent = new ManualResetEvent(false);
string channelName = "hello_my_channel";
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName }, channelGroupName, ChannelGroupCRUDCallback, DummyErrorCallback);
channelGroupManualEvent.WaitOne(10 * 1000, false);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.True(receivedChannelGroupMessage, "WhenChannelGroupIsRequested -> ThenAddChannelShouldReturnSuccess failed.");
}
示例2: ThenAddChannelShouldReturnSuccess
public void ThenAddChannelShouldReturnSuccess()
{
currentUnitTestCase = "ThenAddChannelShouldReturnSuccess";
receivedChannelGroupMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenChannelGroupIsRequested";
unitTest.TestCaseName = "ThenAddChannelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
channelGroupManualEvent = new ManualResetEvent(false);
string channelName = "hello_my_channel";
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName }, channelGroupName, ChannelGroupCRUDCallback, DummyErrorCallback);
channelGroupManualEvent.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedChannelGroupMessage, "WhenChannelGroupIsRequested -> ThenAddChannelShouldReturnSuccess failed.");
pubnub.PubnubUnitTest = null;
pubnub = null;
TestComplete();
});
});
}
示例3: ThenSubscribeShouldReturnReceivedMessage
public void ThenSubscribeShouldReturnReceivedMessage()
{
currentUnitTestCase = "ThenSubscribeShouldReturnReceivedMessage";
receivedMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = "myuuid";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenSubscribedToAChannelGroup";
unitTest.TestCaseName = "ThenSubscribeShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
channelGroupName = "hello_my_group";
string channelName = "hello_my_channel";
subscribeManualEvent = new ManualResetEvent(false);
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName }, channelGroupName, ChannelGroupAddCallback, DummySubscribeErrorCallback);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
if (receivedChannelGroupMessage)
{
subscribeManualEvent = new ManualResetEvent(false);
pubnub.Subscribe<string>("", channelGroupName, ReceivedMessageCallbackWhenSubscribed, SubscribeConnectCallback, DummySubscribeErrorCallback);
Task.Delay(1000);
pubnub.Publish<string>(channelName, "Test for WhenSubscribedToAChannelGroup ThenItShouldReturnReceivedMessage", dummyPublishCallback, DummyPublishErrorCallback);
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
mePublish.WaitOne(manualResetEventsWaitTimeout);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
subscribeManualEvent = new ManualResetEvent(false);
pubnub.Unsubscribe<string>("", channelGroupName, dummyUnsubscribeCallback, SubscribeConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, DummySubscribeErrorCallback);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedMessage, "WhenSubscribedToAChannelGroup --> ThenItShouldReturnReceivedMessage Failed");
}
else
{
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedChannelGroupMessage, "WhenSubscribedToAChannelGroup --> ThenItShouldReturnReceivedMessage Failed");
}
}
示例4: ThenShouldReturnUnsubscribedMessage
public void ThenShouldReturnUnsubscribedMessage()
{
currentUnitTestCase = "ThenShouldReturnUnsubscribedMessage";
receivedMessage = false;
receivedChannelGroupMessage = false;
receivedChannelGroupConnectedMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = "myuuid";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenUnsubscribedToAChannelGroup";
unitTest.TestCaseName = "ThenShouldReturnUnsubscribedMessage";
pubnub.PubnubUnitTest = unitTest;
channelGroupName = "hello_my_group";
string channelName = "hello_my_channel";
unsubscribeManualEvent = new ManualResetEvent(false);
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName }, channelGroupName, ChannelGroupAddCallback, DummySubscribeErrorCallback);
unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
if (receivedChannelGroupMessage)
{
unsubscribeManualEvent = new ManualResetEvent(false);
pubnub.Subscribe<string>("", channelGroupName, DummyMethodChannelSubscribeUserCallback, DummyMethodChannelSubscribeConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
if (receivedChannelGroupConnectedMessage)
{
unsubscribeManualEvent = new ManualResetEvent(false);
pubnub.Unsubscribe<string>("", channelGroupName, DummyMethodUnsubscribeChannelUserCallback, DummyMethodUnsubscribeChannelConnectCallback, DummyMethodUnsubscribeChannelDisconnectCallback, DummyErrorCallback);
unsubscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
}
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.True(receivedMessage, "WhenUnsubscribedToAChannelGroup --> ThenShouldReturnUnsubscribedMessage Failed");
}
else
{
Assert.True(receivedChannelGroupMessage, "WhenUnsubscribedToAChannelGroup --> ThenShouldReturnUnsubscribedMessage Failed");
}
}
示例5: ThenMultiSubscribeShouldReturnConnectStatus
public void ThenMultiSubscribeShouldReturnConnectStatus()
{
currentUnitTestCase = "ThenMultiSubscribeShouldReturnConnectStatus";
receivedMessage = false;
receivedChannelGroupMessage1 = false;
receivedChannelGroupMessage2 = false;
expectedCallbackResponses = 2;
currentCallbackResponses = 0;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = "myuuid";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenSubscribedToAChannelGroup";
unitTest.TestCaseName = "ThenMultiSubscribeShouldReturnConnectStatus";
pubnub.PubnubUnitTest = unitTest;
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 6000 : 310 * 1000;
channelGroupName1 = "hello_my_group1";
channelGroupName2 = "hello_my_group2";
string channelName1 = "hello_my_channel1";
string channelName2 = "hello_my_channel2";
string channel1 = "hello_my_channel1";
subscribeManualEvent = new ManualResetEvent(false);
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName1 }, channelGroupName1, ChannelGroupAddCallback, DummySubscribeErrorCallback);
Thread.Sleep(1000);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
subscribeManualEvent = new ManualResetEvent(false);
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName2 }, channelGroupName2, ChannelGroupAddCallback, DummySubscribeErrorCallback);
Thread.Sleep(1000);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
if (receivedChannelGroupMessage1 && receivedChannelGroupMessage2)
{
subscribeManualEvent = new ManualResetEvent(false);
pubnub.Subscribe<string>("", string.Format("{0},{1}", channelGroupName1, channelGroupName2), ReceivedMessageCallbackWhenSubscribed, SubscribeConnectCallback, DummySubscribeErrorCallback);
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedMessage, "WhenSubscribedToAChannelGroup --> ThenMultiSubscribeShouldReturnConnectStatusFailed");
}
else
{
Assert.IsTrue(receivedChannelGroupMessage1 && receivedChannelGroupMessage2, "WhenSubscribedToAChannelGroup --> ThenMultiSubscribeShouldReturnConnectStatusFailed");
}
}
示例6: Main
//.........这里部分代码省略.........
Console.WriteLine();
Console.WriteLine("Running Global HereNow()");
pubnub.GlobalHereNow<string>(globalHereNowShowUUID, globalHereNowIncludeUserState,DisplayReturnMessage, DisplayErrorMessage);
break;
case "29":
Console.WriteLine("ENTER UUID.");
string sessionUUID = Console.ReadLine();
pubnub.ChangeUUID(sessionUUID);
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("UUID = {0}",pubnub.SessionUUID);
Console.ResetColor();
break;
case "38":
Console.WriteLine("Enter namespace");
string addChannelGroupNamespace = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("namespace = {0}", addChannelGroupNamespace));
Console.ResetColor();
Console.WriteLine("Enter channel group name");
string addChannelGroupName = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("channel group name = {0}", addChannelGroupName));
Console.ResetColor();
Console.WriteLine("Enter CHANNEL name. Use comma to enter multiple channels.");
channel = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("Channel = {0}",channel));
Console.ResetColor();
Console.WriteLine();
pubnub.AddChannelsToChannelGroup<string>(channel.Split(','), addChannelGroupNamespace, addChannelGroupName, DisplayReturnMessage, DisplayErrorMessage);
break;
case "39":
Console.WriteLine("Enter namespace");
string removeChannelGroupNamespace = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("namespace = {0}", removeChannelGroupNamespace));
Console.ResetColor();
if (removeChannelGroupNamespace.Trim().Length > 0)
{
Console.WriteLine("Do you want to remove the namespace and all its group names and all its channels? Default is No. Enter Y for Yes, Else just hit ENTER key");
string removeExistingNamespace = Console.ReadLine();
if (removeExistingNamespace.ToLower() == "y")
{
pubnub.RemoveChannelGroupNameSpace<string>(removeChannelGroupNamespace, DisplayReturnMessage, DisplayErrorMessage);
break;
}
}
Console.WriteLine("Enter channel group name");
string removeChannelGroupName = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine(string.Format("channel group name = {0}", removeChannelGroupName));
Console.ResetColor();
if (removeChannelGroupName.Trim().Length <= 0)
{
Console.WriteLine("Channel group not provided. Try again");
break;
}
Console.WriteLine("Do you want to remove the channel group and all its channels? Default is No. Enter Y for Yes, Else just hit ENTER key");
string removeExistingGroup = Console.ReadLine();
示例7: ChannelAndChannelGroupAndWildcardChannelSubscribeShouldReturnReceivedMessage
public void ChannelAndChannelGroupAndWildcardChannelSubscribeShouldReturnReceivedMessage()
{
receivedMessage = false;
currentTestCase = "ChannelAndChannelGroupAndWildcardChannelSubscribeShouldReturnReceivedMessage";
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = "myuuid";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenSubscribedToWildcardChannel";
unitTest.TestCaseName = "ChannelAndChannelGroupAndWildcardChannelSubscribeShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
string wildCardSubscribeChannel = "foo.*";
string subChannelName = "hello_my_channel";
string commaDelimitedChannel = string.Format("{0},{1}", subChannelName, wildCardSubscribeChannel);
channelGroupName = "hello_my_group";
string channelAddForGroup = "hello_my_channel1";
string pubWildChannelName = "foo.a";
mreSubscribe = new ManualResetEvent(false);
pubnub.AddChannelsToChannelGroup<string>(new string[] { channelAddForGroup }, channelGroupName, ChannelGroupAddCallback, DummyErrorCallback);
mreSubscribe.WaitOne(manualResetEventsWaitTimeout);
mreSubscribe = new ManualResetEvent(false);
mreSubscribeConnect = new ManualResetEvent(false);
pubnub.Subscribe<string>(channel: commaDelimitedChannel, channelGroup: channelGroupName, subscribeCallback: ReceivedMessageCallbackWhenSubscribed, connectCallback: SubscribeDummyMethodForConnectCallback, wildcardPresenceCallback: null, errorCallback: DummyErrorCallback);
mreSubscribeConnect.WaitOne(manualResetEventsWaitTimeout);
mrePublish = new ManualResetEvent(false);
publishedMessage = "Test for cg";
pubnub.Publish<string>(channel: channelAddForGroup, message: publishedMessage, userCallback: dummyPublishCallback, errorCallback: DummyErrorCallback);
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
mrePublish.WaitOne(manualResetEventsWaitTimeout);
if (isPublished)
{
Thread.Sleep(1000);
mrePublish = new ManualResetEvent(false);
publishedMessage = "Test for wc";
pubnub.Publish<string>(channel: pubWildChannelName, message: publishedMessage, userCallback: dummyPublishCallback, errorCallback: DummyErrorCallback);
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
mrePublish.WaitOne(manualResetEventsWaitTimeout);
}
if (isPublished)
{
Thread.Sleep(1000);
mrePublish = new ManualResetEvent(false);
publishedMessage = "Test for normal ch";
pubnub.Publish<string>(channel: subChannelName, message: publishedMessage, userCallback: dummyPublishCallback, errorCallback: DummyErrorCallback);
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
mrePublish.WaitOne(manualResetEventsWaitTimeout);
}
endOfPublish = true;
if (isPublished)
{
Thread.Sleep(1000);
mreSubscribe.WaitOne(manualResetEventsWaitTimeout);
mreUnsubscribe = new ManualResetEvent(false);
pubnub.Unsubscribe<string>(commaDelimitedChannel, channelGroupName, dummyUnsubscribeCallback, SubscribeDummyMethodForConnectCallback, UnsubscribeDummyMethodForDisconnectCallback, null, DummyErrorCallback);
mreUnsubscribe.WaitOne(manualResetEventsWaitTimeout);
}
Assert.IsTrue(receivedMessage, "WhenSubscribedToWildcardChannel --> ChannelAndChannelGroupAndWildcardChannelSubscribeShouldReturnReceivedMessage Failed");
pubnub.PubnubUnitTest = null;
pubnub.EndPendingRequests();
pubnub = null;
}
示例8: ThenSubscribeShouldReturnConnectStatus
public void ThenSubscribeShouldReturnConnectStatus()
{
currentUnitTestCase = "ThenSubscribeShouldReturnConnectStatus";
receivedMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
pubnub.SessionUUID = "myuuid";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenSubscribedToAChannelGroup";
unitTest.TestCaseName = "ThenSubscribeShouldReturnConnectStatus";
pubnub.PubnubUnitTest = unitTest;
channelGroupName = "hello_my_group";
string channelName = "hello_my_channel";
subscribeManualEvent = new ManualResetEvent(false);
EnqueueCallback(() => pubnub.AddChannelsToChannelGroup<string>(new string[] { channelName }, channelGroupName, ChannelGroupAddCallback, DummySubscribeErrorCallback));
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
if (receivedChannelGroupMessage)
{
subscribeManualEvent = new ManualResetEvent(false);
EnqueueCallback(() => pubnub.Subscribe<string>("", channelGroupName, ReceivedMessageCallbackWhenSubscribed, SubscribeConnectCallback, DummySubscribeErrorCallback));
Thread.Sleep(1000);
manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
subscribeManualEvent.WaitOne(manualResetEventsWaitTimeout);
EnqueueCallback(() => pubnub.EndPendingRequests());
EnqueueCallback(() => Assert.IsTrue(receivedMessage, "WhenSubscribedToAChannelGroup --> ThenSubscribeShouldReturnConnectStatus Failed"));
}
else
{
EnqueueCallback(() => Assert.IsTrue(receivedChannelGroupMessage, "WhenSubscribedToAChannelGroup --> ThenSubscribeShouldReturnConnectStatus Failed"));
}
EnqueueCallback(() =>
{
pubnub.PubnubUnitTest = null;
pubnub = null;
}
);
EnqueueTestComplete();
});
}