void Update()
{
string host = “localhost”;
string username = “admin”;
string vpnname = “default”;
string password = “admin”;
if (!_isPressedRed && GetValueRed() + threshold >= 1)
PressedRed();
if (_isPressedRed && GetValueRed() - threshold <= 0)
ReleasedRed();
ContextFactoryProperties cfp = new ContextFactoryProperties()
{
SolClientLogLevel = SolLogLevel.Warning
};
cfp.LogToConsoleError();
ContextFactory.Instance.Init(cfp);
try
{
using (IContext context = ContextFactory.Instance.CreateContext(new ContextProperties(), null))
{
TopicPublisher topicPublisher = new TopicPublisher()
{
VPNName = vpnname,
UserName = username,
Password = password
};
topicPublisher.Run(context, host);
}
using (IContext context = ContextFactory.Instance.CreateContext(new ContextProperties(), null))
{
TopicSubscriber topicSubscriber = new TopicSubscriber()
{
VPNName = vpnname,
UserName = username,
Password = password
};
topicSubscriber.Run(context, host);
}
}
catch (Exception ex)
{
Console.WriteLine(“Exception thrown: {0}”, ex.Message);
}
finally
{
ContextFactory.Instance.Cleanup();
}
Console.WriteLine(“Finished.”);
Console.ReadLine(); …
And then I used other methods like previous script actually I run publisher and subscriber with the same cfp and same context But it didnt work.