I should mention that I can run subscriber and publisher in two different unity file andeach of them individually works and I can publish to solace Broker and receive from it now I need to run them with each other.
My publisher code is :
public class RedButton : MonoBehaviour
{
public static string Re;
[SerializeFeild] private float threshold = 0.1f;
[SerializeFeild] private float deadzone = 0.025f;
private bool _isPressedRed;
private Vector3 _stratPosRed;
private ConfigurableJoint _jointRed;
public UnityEvent onPressedRed, onReleasedRed;
void Start()
{
_stratPosRed = transform.localPosition;
_jointRed = GetComponent();
}
void Update()
{
string host = “localhost”;
string username = “admin”;
string vpnname = “default”;
string password = “admin”;
if (!_isPressedRed && GetValueRed() + threshold >= 1)
PressedRed();
(_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);
}
}
catch (Exception ex)
{
Console.WriteLine(“Exception thrown: {0}”, ex.Message);
}
finally
{
ContextFactory.Instance.Cleanup();
}
Console.WriteLine(“Finished.”);
Console.ReadLine();
}
IEnumerator Wait()
{
yield return new WaitForSeconds(5);
}