Example #1
0
    public void Start()
    {
        // Load the config file from StreamingAssets.
        string configText  = "";
        bool   configError = false;

        try
        {
            configText = File.ReadAllText(Path.Combine(Application.streamingAssetsPath, CONFIG_FILE));
        }
        catch
        {
            configError = true;
        }


        if (string.IsNullOrEmpty(configText))
        {
            configError = true;
        }

        var amqpConnection = new AmqpConnection();

        if (!configError)
        {
            var config = StompConfig.ConvertToObject(configText);
            amqpConnection.Name               = "StompConfig";
            amqpConnection.Host               = "localhost";
            amqpConnection.AmqpPort           = 5672;    // int.Parse(config.port);
            amqpConnection.Username           = "******"; //config.username;
            amqpConnection.Password           = "******"; //config.password;
            amqpConnection.VirtualHost        = vhost;   //config.virtual_host;
            amqpConnection.WebPort            = 15674;
            amqpConnection.ReconnectInterval  = 5;
            amqpConnection.RequestedHeartBeat = 30;
        }
        else
        {
            print("ERROR : Config file invalid!!!!!!!!");
        }

        AmqpClient.AddConnection(amqpConnection);

        client            = GetComponent <AmqpClient>();
        client.enabled    = true;
        client.Connection = amqpConnection.Name;
        client.ConnectToHost();

        _watson_listener = GetComponent <WatsonListener>();
    }