本文整理汇总了C#中Pubnub.GrantAccess方法的典型用法代码示例。如果您正苦于以下问题:C# Pubnub.GrantAccess方法的具体用法?C# Pubnub.GrantAccess怎么用?C# Pubnub.GrantAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pubnub
的用法示例。
在下文中一共展示了Pubnub.GrantAccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled) return;
receivedGrantMessage = false;
currentTestCase = "Init";
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "foo.*";
mreGrant = new ManualResetEvent(false);
pubnub.GrantAccess<string>(channel, true, true, 20, ThenSubscribeInitializeShouldReturnGrantMessage, DummyErrorCallback);
Thread.Sleep(1000);
mreGrant.WaitOne();
if (receivedGrantMessage)
{
channel = "hello_my_channel";
mreGrant = new ManualResetEvent(false);
pubnub.GrantAccess<string>(channel, true, true, 20, ThenSubscribeInitializeShouldReturnGrantMessage, DummyErrorCallback);
Thread.Sleep(1000);
mreGrant.WaitOne();
}
if (receivedGrantMessage)
{
channel = "hello_my_channel1";
mreGrant = new ManualResetEvent(false);
pubnub.GrantAccess<string>(channel, true, true, 20, ThenSubscribeInitializeShouldReturnGrantMessage, DummyErrorCallback);
Thread.Sleep(1000);
mreGrant.WaitOne();
}
if (receivedMessage)
{
channelGroupName = "hello_my_group";
mreGrant = new ManualResetEvent(false);
pubnub.ChannelGroupGrantAccess<string>(channelGroupName, true, true, 20, ThenSubscribeInitializeShouldReturnGrantMessage, DummyErrorCallback);
Thread.Sleep(1000);
mreGrant.WaitOne();
}
pubnub.EndPendingRequests();
pubnub = null;
Assert.IsTrue(receivedGrantMessage, "WhenSubscribedToWildcardChannel Grant access failed.");
}
示例2: ThenSubKeyLevelWithReadShouldReturnSuccess
public void ThenSubKeyLevelWithReadShouldReturnSuccess()
{
grantAccessCallbackInvoked = false;
currentUnitTestCase = "ThenSubKeyLevelWithReadShouldReturnSuccess";
receivedGrantMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGrantIsRequested";
unitTest.TestCaseName = "ThenSubKeyLevelWithReadShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
if (PubnubCommon.PAMEnabled)
{
EnqueueCallback(() => pubnub.GrantAccess<string>("", true, false, 5, AccessToSubKeyLevelCallback, DummyErrorCallback));
//Thread.Sleep(1000);
EnqueueConditional(() => grantAccessCallbackInvoked);
EnqueueCallback(() => Assert.IsTrue(receivedGrantMessage, "WhenGrantIsRequested -> ThenSubKeyLevelWithReadShouldReturnSuccess failed."));
}
else
{
EnqueueCallback(() => Assert.Inconclusive("PAM Not Enabled for WhenGrantIsRequested -> ThenSubKeyLevelWithReadShouldReturnSuccess."));
}
EnqueueTestComplete();
}
示例3: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled)
{
TestComplete();
return;
}
receivedGrantMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel,hello_my_channel1,hello_my_channel2";
mreGrant = new ManualResetEvent(false);
pubnub.GrantAccess<string>(channel, true, true, 20, ThenSubscriberInitializeShouldReturnGrantMessage, DummyErrorCallback);
mreGrant.WaitOne(60 * 1000); //1 minute
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedGrantMessage, "WhenAClientIsPresent Grant access failed.");
TestComplete();
});
});
}
示例4: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled)
{
Assert.Inconclusive("WhenAClientIsPresent Grant access failed.");
return;
}
receivedGrantMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
pubnub.GrantAccess<string>(channel, true, true, 20, ThenSubscriberInitializeShouldReturnGrantMessage, DummyErrorCallback);
//Thread.Sleep(1000);
grantManualEvent.WaitOne();
Assert.IsTrue(receivedGrantMessage, "WhenAClientIsPresent Grant access failed.");
}
示例5: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled)
{
EnqueueTestComplete();
return;
}
receivedGrantMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init2";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel,hello_my_channel-pnpres";
EnqueueCallback(() => pubnub.GrantAccess<string>(channel, true, true, 20, ThenPresenceInitializeShouldReturnGrantMessage, DummyErrorCallback));
mreGrant.WaitOne(310 * 1000);
EnqueueCallback(() => Assert.IsTrue(receivedGrantMessage, "WhenAClientIsPresent Grant access failed."));
EnqueueTestComplete();
});
}
示例6: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled)
{
return;
}
receivedGrantMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
mreGrant = new ManualResetEvent(false);
pubnub.GrantAccess<string>(channel, true, true, 20, ThenPushInitializeShouldReturnGrantMessage, DummyErrorCallback);
mreGrant.WaitOne(60 * 1000);
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedGrantMessage, "WhenPushIsRequested Grant access failed.");
}
示例7: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled)
{
EnqueueTestComplete();
return;
}
receivedGrantMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel,hello_my_channel1,hello_my_channel2";
EnqueueCallback(() => pubnub.GrantAccess<string>(channel, true, true, 20, ThenSubscribeInitializeShouldReturnGrantMessage, DummyErrorCallback));
//Thread.Sleep(1000);
EnqueueConditional(() => grantInitCallbackInvoked);
EnqueueCallback(() => Assert.IsTrue(receivedGrantMessage, "WhenSubscribedToAChannel Grant access failed."));
EnqueueTestComplete();
}
示例8: AtChannelLevel
public void AtChannelLevel()
{
if (!PubnubCommon.PAMEnabled)
{
Assert.Ignore("PAM not enabled; GenerateSampleGrant -> AtChannelLevel.");
return;
}
if (!PubnubCommon.EnableStubTest)
{
receivedGrantMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
for (int index = 0; index < sampleCount; index++)
{
grantManualEvent = new ManualResetEvent(false);
string channelName = string.Format("csharp-pam-cl-channel-{0}", index);
pubnub.GrantAccess<string>(channelName, true, true, UserCallbackForSampleGrantAtChannelLevel, ErrorCallbackForSampleGrantAtChannelLevel);
grantManualEvent.WaitOne();
}
pubnub.EndPendingRequests();
pubnub = null;
Assert.True(receivedGrantMessage, "GenerateSampleGrant -> AtChannelLevel failed.");
}
else
{
Assert.Ignore("Only for live test; GenerateSampleGrant -> AtChannelLevel.");
}
}
示例9: ThenSubKeyLevelWithReadShouldReturnSuccess
public void ThenSubKeyLevelWithReadShouldReturnSuccess()
{
currentUnitTestCase = "ThenSubKeyLevelWithReadShouldReturnSuccess";
mreGrant = new ManualResetEvent(false);
receivedGrantMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGrantIsRequested";
unitTest.TestCaseName = "ThenSubKeyLevelWithReadShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
if (PubnubCommon.PAMEnabled)
{
EnqueueCallback(() => pubnub.GrantAccess<string>("", true, false, 5, AccessToSubKeyLevelCallback, DummyErrorCallback));
mreGrant.WaitOne(310 * 1000);
EnqueueCallback(() => Assert.IsTrue(receivedGrantMessage, "WhenGrantIsRequested -> ThenSubKeyLevelWithReadShouldReturnSuccess failed."));
}
else
{
EnqueueCallback(() => Assert.Inconclusive("PAM Not Enabled for WhenGrantIsRequested -> ThenSubKeyLevelWithReadShouldReturnSuccess."));
}
EnqueueTestComplete();
});
}
示例10: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled)
{
Assert.Inconclusive("WhenAClientIsPresent Grant access failed.");
return;
}
receivedGrantMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
pubnub.GrantAccess<string>(channel, true, true, 20, ThenDetailedHistoryInitializeShouldReturnGrantMessage, DummyErrorCallback);
//Thread.Sleep(1000);
grantManualEvent.WaitOne();
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedGrantMessage, "WhenAClientIsPresent Grant access failed.");
});
});
}
示例11: ThenSubKeyLevelWithReadShouldReturnSuccess
public void ThenSubKeyLevelWithReadShouldReturnSuccess()
{
currentUnitTestCase = "ThenSubKeyLevelWithReadShouldReturnSuccess";
receivedGrantMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenGrantIsRequested";
unitTest.TestCaseName = "ThenSubKeyLevelWithReadShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
if (PubnubCommon.PAMEnabled)
{
pubnub.GrantAccess<string>("", true, false, 5, AccessToSubKeyLevelCallback, DummyErrorCallback);
Thread.Sleep(1000);
grantManualEvent.WaitOne();
Assert.IsTrue(receivedGrantMessage, "WhenGrantIsRequested -> ThenSubKeyLevelWithReadShouldReturnSuccess failed.");
} else
{
Assert.Ignore("PAM Not Enabled for WhenGrantIsRequested -> ThenSubKeyLevelWithReadShouldReturnSuccess.");
}
}
示例12: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled) return;
receivedGrantMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
pubnub.GrantAccess<string>(channel, true, true, 20, ThenUnsubscribeInitializeShouldReturnGrantMessage, DummyErrorCallback);
Thread.Sleep(1000);
grantManualEvent.WaitOne();
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedGrantMessage, "WhenUnsubscribedToAChannel Grant access failed.");
}
示例13: UserCallbackForCleanUpAccessAtChannelLevel
void UserCallbackForCleanUpAccessAtChannelLevel(string receivedMessage)
{
try
{
Console.WriteLine(receivedMessage);
if (!string.IsNullOrEmpty(receivedMessage) && !string.IsNullOrEmpty(receivedMessage.Trim()))
{
object[] serializedMessage = JsonConvert.DeserializeObject<object[]>(receivedMessage);
JContainer dictionary = serializedMessage [0] as JContainer;
if (dictionary != null)
{
int statusCode = dictionary.Value<int>("status");
string statusMessage = dictionary.Value<string>("message");
if (statusCode == 200 && statusMessage.ToLower() == "success")
{
var payload = dictionary.Value<JContainer>("payload");
if (payload != null)
{
bool read = payload.Value<bool>("r");
bool write = payload.Value<bool>("w");
var channels = payload.Value<JContainer>("channels");
if (channels != null && channels.Count > 0)
{
Console.WriteLine("CleanupGrant / AtUserLevel / UserCallbackForCleanUpAccess - Channel Count = {0}", channels.Count);
foreach (JToken channel in channels.Children())
{
if (channel is JProperty)
{
var channelProperty = channel as JProperty;
if (channelProperty != null)
{
string channelName = channelProperty.Name;
Console.WriteLine(channelName);
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
pubnub.GrantAccess<string>(channelName, false, false, UserCallbackForRevokeAccess, ErrorCallbackForRevokeAccess);
revokeManualEvent.WaitOne();
}
}
}
}
string level = payload.Value<string>("level");
if (level == "subkey")
{
receivedAuditMessage = true;
}
}
}
}
}
} catch (Exception ex)
{
Console.WriteLine("UserCallbackForCleanUpAccessAtChannelLevel" + ex.ToString());
} finally
{
auditManualEvent.Set();
}
}
示例14: AtUserLevel
public void AtUserLevel ()
{
if (!PubnubCommon.EnableStubTest) {
receivedGrantMessage = false;
Pubnub pubnub = new Pubnub (PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
for (int index = 0; index < sampleCount; index++) {
string channelName = string.Format ("csharp-pam-ul-channel-{0}", index);
pubnub.AuthenticationKey = string.Format ("csharp-pam-authkey-0-{0},csharp-pam-authkey-1-{1}", index, index);
pubnub.GrantAccess<string> (channelName, true, true, UserCallbackForSampleGrantAtUserLevel, ErrorCallbackForSampleGrantAtUserLevel);
grantManualEvent.WaitOne ();
}
Assert.True (receivedGrantMessage, "GenerateSampleGrant -> AtUserLevel failed.");
} else {
Assert.Ignore ("Only for live test; GenerateSampleGrant -> AtUserLevel.");
}
}
示例15: Init
public void Init()
{
if (!PubnubCommon.PAMEnabled) return;
receivedGrantMessage = false;
pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "GrantRequestUnitTest";
unitTest.TestCaseName = "Init";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel,hello_my_channel-pnpres";
pubnub.GrantAccess<string>(channel, true, true, 20, ThenPresenceInitializeShouldReturnGrantMessage, DummyErrorCallback);
grantManualEvent.WaitOne(manualResetEventsWaitTimeout, false);
pubnub.EndPendingRequests();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.True(receivedGrantMessage, "WhenAClientIsPresent Grant access failed.");
}