Install this extension if you want to use PubNub and your app targets traditional .NET framework.
Check RingCentral.Net.PubnubPCL if your app targets .NET Core, Mono, Xamarin...etc.
var rc = new RestClient(
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_ID"),
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RINGCENTRAL_SERVER_URL")
);
var pubNubExtension = new PubNubExtension();
await rc.InstallExtension(pubNubExtension);
var eventFilters = new[]
{
"/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true",
"/restapi/v1.0/account/~/extension/~/message-store"
};
var subscription = await pubNubExtension.Subscribe(eventFilters, message =>
{
// do something with message
});
If you create multiple subscriptions in a single app and run the app in .NET Framework environment, you may experience notifications delay. Delay time is around 4 minutes and 30 seconds.
A solution/workaround is to add the following to your app.config
file:
<system.net>
<connectionManagement>
<add address = "*" maxconnection = "999" />
</connectionManagement>
</system.net>
Notes:
- If you run your app in .NET Core environment, you will not have this issue.
- If you only create one subscription in your code, you will not have this issue either.
- This is because by default only 2 connections to a server is allowed.
- More information FYI: https://stackoverflow.com/a/49868185/862862
This extension is inspired by its TypeScript counterpart, check its documentation for more information.