本文整理汇总了C#中Pubnub类的典型用法代码示例。如果您正苦于以下问题:C# Pubnub类的具体用法?C# Pubnub怎么用?C# Pubnub使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pubnub类属于命名空间,在下文中一共展示了Pubnub类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ThenSubscribeShouldReturnConnectStatus
public void ThenSubscribeShouldReturnConnectStatus()
{
receivedConnectMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenSubscribedToAChannel";
unitTest.TestCaseName = "ThenSubscribeShouldReturnConnectStatus";
pubnub.PubnubUnitTest = unitTest;
string channel = "my/channel";
pubnub.Subscribe<string>(channel, ReceivedMessageCallbackYesConnect, ConnectStatusCallback);
meSubscribeYesConnect.WaitOne(310 * 1000);
Thread.Sleep(200);
pubnub.Unsubscribe<string>(channel, dummyUnsubCallback);
meUnsubscribe.WaitOne(310 * 1000);
Thread.Sleep(200);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedConnectMessage, "WhenSubscribedToAChannel --> ThenSubscribeShouldReturnConnectStatus Failed");
TestComplete();
});
});
}
开发者ID:hellogurus,项目名称:pubnub-api,代码行数:29,代码来源:WhenSubscribedToAChannel.cs
示例2: ThenChannelLevelShouldReturnSuccess
public void ThenChannelLevelShouldReturnSuccess()
{
currentUnitTestCase = "ThenChannelLevelShouldReturnSuccess";
receivedAuditMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAuditIsRequested";
unitTest.TestCaseName = "ThenChannelLevelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
if (PubnubCommon.PAMEnabled)
{
mreAudit = new ManualResetEvent(false);
pubnub.AuditAccess<string>(channel, AccessToChannelLevelCallback, DummyErrorCallback);
mreAudit.WaitOne(60 * 1000);
Assert.IsTrue(receivedAuditMessage, "WhenAuditIsRequested -> ThenChannelLevelShouldReturnSuccess failed.");
}
else
{
Assert.Inconclusive("PAM Not Enabled for WhenAuditIsRequested -> ThenChannelLevelShouldReturnSuccess");
}
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
TestComplete();
});
});
}
开发者ID:jdstroy,项目名称:c-sharp,代码行数:35,代码来源:WhenAuditIsRequested.cs
示例3: NullMessage
public void NullMessage()
{
Pubnub pubnub = new Pubnub(
"demo",
"demo",
"",
"",
false
);
string channel = "hello_world";
string message = null;
Common common = new Common();
common.DeliveryStatus = false;
common.Response = null;
pubnub.Publish(channel, message, common.DisplayReturnMessage);
//wait till the response is received from the server
while (!common.DeliveryStatus) ;
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);
}
开发者ID:Vlanta,项目名称:c-sharp,代码行数:25,代码来源:WhenAMessageIsPublished.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: ThenPresenceShouldReturnCustomUUID
public void ThenPresenceShouldReturnCustomUUID()
{
receivedCustomUUID = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnCustomUUID";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
pubnub.Presence<string>(channel, ThenPresenceWithCustomUUIDShouldReturnMessage, PresenceUUIDDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
//since presence expects from stimulus from sub/unsub...
pubnub.SessionUUID = customUUID;
pubnub.Subscribe<string>(channel, DummyMethodForSubscribeUUID, SubscribeUUIDDummyMethodForConnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
subscribeUUIDManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribeUUID, UnsubscribeUUIDDummyMethodForConnectCallback, UnsubscribeUUIDDummyMethodForDisconnectCallback, DummyErrorCallback);
Thread.Sleep(1000);
unsubscribeUUIDManualEvent.WaitOne(2000);
presenceUUIDManualEvent.WaitOne(310 * 1000);
pubnub.EndPendingRequests();
Assert.IsTrue(receivedCustomUUID, "Custom UUID not received");
}
开发者ID:kaido42,项目名称:c-sharp,代码行数:32,代码来源:WhenAClientIsPresented.cs
示例6: 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.");
}
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:25,代码来源:WhenSubscribedToAChannel.cs
示例7: Send_to_standIn
public void Send_to_standIn()
{
var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt");
using(var sut = new PubnubHostTransceiver(cre, "hostchannel"))
{
var standIn = new Pubnub(cre.PublishingKey, cre.SubscriptionKey, cre.SecretKey);
try
{
var standInChannel = Guid.NewGuid().ToString();
var are = new AutoResetEvent(false);
ReadOnlyCollection<object> result = null;
standIn.subscribe(standInChannel, (ReadOnlyCollection<object> _) =>
{
result = _;
are.Set();
});
var ho = new HostOutput{CorrelationId = Guid.NewGuid(), Data = "hello".Serialize(), Portname = "portname"};
sut.SendToStandIn(new Tuple<string, HostOutput>(standInChannel, ho));
Assert.IsTrue(are.WaitOne(5000));
var hoReceived = Convert.FromBase64String((string)((JValue)result[0]).Value).Deserialize() as HostOutput;
Assert.AreEqual(ho.CorrelationId, hoReceived.CorrelationId);
Assert.AreEqual(ho.Data, hoReceived.Data);
Assert.AreEqual(ho.Portname, hoReceived.Portname);
}
finally
{
standIn.subscribe("standIn", _ => {});
}
}
}
开发者ID:kennychou0529,项目名称:NPantaRhei,代码行数:34,代码来源:test_PubnubHostTransceiver.cs
示例8: Receive_from_host
public void Receive_from_host()
{
var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt");
using (var sut = new PubnubStandInTransceiver(cre, "hostchannel"))
{
var are = new AutoResetEvent(false);
HostOutput result = null;
sut.ReceivedFromHost += _ =>
{
result = _;
are.Set();
};
var sender = new Pubnub(cre.PublishingKey, cre.SubscriptionKey);
var ho = new HostOutput {CorrelationId = Guid.NewGuid(), Data = "hello".Serialize(), Portname = "portname"};
sender.publish(sut.StandInEndpointAddress, ho.Serialize(), _ => { });
Assert.IsTrue(are.WaitOne(5000));
Assert.AreEqual(ho.CorrelationId, result.CorrelationId);
Assert.AreEqual(ho.Data, result.Data);
Assert.AreEqual(ho.Portname, result.Portname);
}
}
开发者ID:kennychou0529,项目名称:NPantaRhei,代码行数:25,代码来源:test_PubnubStandInTransceiver.cs
示例9: ThenPresenceShouldReturnReceivedMessage
public void ThenPresenceShouldReturnReceivedMessage()
{
receivedPresenceMessage = false;
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
string channel = "my/channel";
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
pubnub.Presence<string>(channel, ThenPresenceShouldReturnMessage);
//since presence expects from stimulus from sub/unsub...
pubnub.Subscribe<string>(channel, DummyMethodForSubscribe);
subscribeManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe);
unsubscribeManualEvent.WaitOne(2000);
pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSub);
presenceUnsubscribeEvent.WaitOne(2000);
presenceManualEvent.WaitOne(310 * 1000);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
Assert.IsTrue(receivedPresenceMessage, "Presence message not received");
TestComplete();
});
});
}
开发者ID:ericflecher,项目名称:pubnub-api,代码行数:33,代码来源:WhenAClientIsPresented.cs
示例10: ThenPresenceShouldReturnCustomUUID
public void ThenPresenceShouldReturnCustomUUID()
{
receivedCustomUUID = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnCustomUUID";
pubnub.PubnubUnitTest = unitTest;
string channel = "my/channel";
pubnub.Presence<string>(channel, ThenPresenceWithCustomUUIDShouldReturnMessage);
//since presence expects from stimulus from sub/unsub...
pubnub.SessionUUID = customUUID;
pubnub.Subscribe<string>(channel, DummyMethodForSubscribeUUID);
subscribeUUIDManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribeUUID);
unsubscribeUUIDManualEvent.WaitOne(2000);
presenceUUIDManualEvent.WaitOne(310 * 1000);
pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSubUUID);
presenceUnsubscribeUUIDEvent.WaitOne();
Assert.IsTrue(receivedCustomUUID, "Custom UUID not received");
}
开发者ID:ericflecher,项目名称:pubnub-api,代码行数:30,代码来源:WhenAClientIsPresented.cs
示例11: 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 = "Init3";
pubnub.PubnubUnitTest = unitTest;
EnqueueCallback(() => pubnub.ChannelGroupGrantAccess<string>(channelGroupName, true, true, 20, ThenChannelGroupInitializeShouldReturnGrantMessage, DummySubscribeErrorCallback));
grantManualEvent.WaitOne(310 * 1000);
EnqueueCallback(() => Assert.IsTrue(receivedGrantMessage, "WhenSubscribedToAChannelGroup Grant access failed."));
EnqueueCallback(() =>
{
pubnub.PubnubUnitTest = null;
pubnub = null;
}
);
EnqueueTestComplete();
});
}
开发者ID:RecursosOnline,项目名称:c-sharp,代码行数:32,代码来源:WhenSubscribedToAChannelGroup.cs
示例12: ThenPresenceShouldReturnReceivedMessage
public void ThenPresenceShouldReturnReceivedMessage()
{
receivedPresenceMessage = false;
Pubnub pubnub = new Pubnub("demo", "demo", "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAClientIsPresented";
unitTest.TestCaseName = "ThenPresenceShouldReturnReceivedMessage";
pubnub.PubnubUnitTest = unitTest;
string channel = "my/channel";
pubnub.Presence<string>(channel, ThenPresenceShouldReturnMessage);
//since presence expects from stimulus from sub/unsub...
pubnub.Subscribe<string>(channel, DummyMethodForSubscribe);
subscribeManualEvent.WaitOne(2000);
pubnub.Unsubscribe<string>(channel, DummyMethodForUnSubscribe);
unsubscribeManualEvent.WaitOne(2000);
presenceManualEvent.WaitOne(310 * 1000);
pubnub.PresenceUnsubscribe<string>(channel, DummyMethodForPreUnSub);
presenceUnsubscribeEvent.WaitOne();
Assert.IsTrue(receivedPresenceMessage, "Presence message not received");
}
开发者ID:ericflecher,项目名称:pubnub-api,代码行数:29,代码来源:WhenAClientIsPresented.cs
示例13: ThenNoExistChannelShouldReturnNotSubscribed
public void ThenNoExistChannelShouldReturnNotSubscribed()
{
receivedNotSubscribedMessage = false;
mreUnsubscribe = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem((s) =>
{
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenUnsubscribedToAChannel";
unitTest.TestCaseName = "ThenNoExistChannelShouldReturnNotSubscribed";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
EnqueueCallback(() => pubnub.Unsubscribe<string>(channel, DummyMethodNoExistChannelUnsubscribeChannelUserCallback, DummyMethodNoExistChannelUnsubscribeChannelConnectCallback, DummyMethodNoExistChannelUnsubscribeChannelDisconnectCallback1, NoExistChannelErrorCallback));
mreUnsubscribe.WaitOne(310 * 1000);
EnqueueCallback(() => pubnub.EndPendingRequests());
EnqueueCallback(() => Assert.IsTrue(receivedNotSubscribedMessage, "WhenUnsubscribedToAChannel --> ThenNoExistChannelShouldReturnNotSubscribed Failed"));
EnqueueTestComplete();
});
}
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:25,代码来源:WhenUnsubscribedToAChannel.cs
示例14: 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";
EnqueueCallback(() => pubnub.GrantAccess<string>(channel, true, true, 20, ThenPublishInitializeShouldReturnGrantMessage, DummyErrorCallback));
//Thread.Sleep(1000);
EnqueueConditional(() => grantInitCallbackInvoked);
EnqueueCallback(() => Assert.IsTrue(receivedGrantMessage, "WhenAClientIsPresent Grant access failed."));
EnqueueTestComplete();
}
开发者ID:Evgeniy20,项目名称:c-sharp,代码行数:28,代码来源:WhenAMessageIsPublished.cs
示例15: 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();
});
});
}
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:31,代码来源:WhenSubscribedToAChannel.cs
示例16: Post
public async Task<HttpResponseMessage> Post(string sessionKey, string channel)
{
string folderName = "_TemporaryFiles";
string PATH = HttpContext.Current.Server.MapPath("~/" + folderName);
string rootUrl = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, String.Empty);
if (Request.Content.IsMimeMultipartContent())
{
var streamProvider = new MultipartFormDataStreamProvider(PATH);
//var task = Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith<IEnumerable<FileDesc>>(t =>
//{
// //if (t.IsFaulted || t.IsCanceled)
// //{
// // throw new HttpResponseException(HttpStatusCode.BadGateway);
// //}
// var fileInfo = streamProvider.FileData.Select(i =>
// {
// var info = new FileInfo(i.LocalFileName);
// return new FileDesc(info.Name, rootUrl+"/"+folderName+"/"+info.Name, info.Length);
// });
// return fileInfo;
//});
//return task;
try
{
// Read the form data.
await Request.Content.ReadAsMultipartAsync(streamProvider);
Pubnub pubnub = new Pubnub("demo", "demo");
string pubnubChannel = channel;
//var dbUser = unitOfWork.Users.All().FirstOrDefault(x => x.Sessionkey == sessionkey);
var uploader = new DropboxUploader();
List<string> urls = new List<string>();
foreach (MultipartFileData file in streamProvider.FileData)
{
//Trace.WriteLine(file.Headers.ContentDisposition.FileName);
//Trace.WriteLine("Server file path: " + file.LocalFileName);
string fileName = file.LocalFileName.Normalize();
var url = uploader.UploadFileToDropBox(fileName.Trim(), file.Headers.ContentDisposition.FileName.Replace("\"", ""));
urls.Add(url.ToString());
//dbUser.ProfilePicture = url;
pubnub.Publish(pubnubChannel, url.ToString(), (object obj) => {});
//break;
}
return Request.CreateResponse(HttpStatusCode.OK, urls);
}
catch (System.Exception e)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
}
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}
}
开发者ID:nnaidenov,项目名称:WebService-TeamTimon,代码行数:60,代码来源:UploadController.cs
示例17: 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();
});
}
开发者ID:jonasduerto,项目名称:c-sharp,代码行数:27,代码来源:WhenAClientIsPresented.cs
示例18: 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.");
}
}
开发者ID:jugalkishor-sujal,项目名称:c-sharp,代码行数:25,代码来源:WhenGrantIsRequested.cs
示例19: Receive_from_standIn
public void Receive_from_standIn()
{
var cre = PubnubCredentials.LoadFrom("pubnub credentials.txt");
using (var sut = new PubnubHostTransceiver(cre, "hostchannel"))
{
var are = new AutoResetEvent(false);
HostInput result = null;
sut.ReceivedFromStandIn += _ =>
{
result = _;
are.Set();
};
var standIn = new Pubnub(cre.PublishingKey, cre.SubscriptionKey, cre.SecretKey);
var hi = new HostInput{CorrelationId = Guid.NewGuid(), Data = "hello".Serialize(), Portname = "portname", StandInEndpointAddress = "endpoint"};
standIn.publish("hostchannel", hi.Serialize(), _ => { });
Assert.IsTrue(are.WaitOne(5000));
Assert.AreEqual(hi.CorrelationId, result.CorrelationId);
Assert.AreEqual(hi.Data, result.Data);
Assert.AreEqual(hi.Portname, result.Portname);
Assert.AreEqual(hi.StandInEndpointAddress, result.StandInEndpointAddress);
}
}
开发者ID:kennychou0529,项目名称:NPantaRhei,代码行数:26,代码来源:test_PubnubHostTransceiver.cs
示例20: ThenChannelLevelShouldReturnSuccess
public void ThenChannelLevelShouldReturnSuccess()
{
currentUnitTestCase = "ThenChannelLevelShouldReturnSuccess";
receivedAuditMessage = false;
Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, PubnubCommon.SecretKey, "", false);
PubnubUnitTest unitTest = new PubnubUnitTest();
unitTest.TestClassName = "WhenAuditIsRequested";
unitTest.TestCaseName = "ThenChannelLevelShouldReturnSuccess";
pubnub.PubnubUnitTest = unitTest;
string channel = "hello_my_channel";
if (PubnubCommon.PAMEnabled)
{
auditManualEvent = new ManualResetEvent(false);
pubnub.AuditAccess<string>(channel, AccessToChannelLevelCallback, DummyErrorCallback);
Task.Delay(1000);
auditManualEvent.WaitOne();
pubnub.PubnubUnitTest = null;
pubnub = null;
Assert.IsTrue(receivedAuditMessage, "WhenAuditIsRequested -> ThenChannelLevelShouldReturnSuccess failed.");
}
else
{
Assert.Inconclusive("PAM Not Enabled for WhenAuditIsRequested -> ThenChannelLevelShouldReturnSuccess");
}
}
开发者ID:pubnub,项目名称:c-sharp,代码行数:32,代码来源:WhenAuditIsRequested.cs
注:本文中的Pubnub类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论