public async Task <ActionResult> GetObj()
        {
            var vagas = await MQTTConnector.ReadStorage();

            if (vagas != null)
            {
                var vagasJson = new List <JObject>();

                foreach (var vaga in vagas)
                {
                    var vagaJson = JObject.FromObject(new
                    {
                        vaga
                    });
                    vagasJson.Add(vagaJson);
                }

                var json = JArray.FromObject(vagasJson.ToArray());

                return(Ok(json));
            }
            else
            {
                return(new StatusCodeResult(500));
            }
        }
Ejemplo n.º 2
0
        public MQTTConnector CreateConnector(string serverUrl, int serverPort, string userId, string password)
        {
            MQTTConnector connection = GameObject.Find(IMQTTConnector.MQTT_CONNECTOR).GetComponent <MQTTConnector>();

            connection.Connect(serverUrl, serverPort, userId, password);
            connection.InitTopics();
            return(connection);
        }
Ejemplo n.º 3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
     Task.Run(async() =>
     {
         await MQTTConnector.Start();
     });
 }
Ejemplo n.º 4
0
        public QCCondition(TickableManager tickableManager, IAciEventManager eventManager, MQTTConnector mqttConnector)
        {
            m_TickableManager = tickableManager;
            m_EventManager    = eventManager;
            m_MqttConnector   = mqttConnector;

            m_TickableManager.Add(this);
            RegisterForEvents();
        }
Ejemplo n.º 5
0
        void OnGUI()
        {
            if (Application.platform == RuntimePlatform.Android)
            {
                if (GUI.Button(new Rect(20, 25, 200, 20), "Quitter! (Android)"))
                {
                    //connector.Disconnect();
                    Application.Quit();
                }
            }

            if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor)
            {
                if (GUI.Button(new Rect(20, 25, 120, 20), "Quitter! (MacOS)"))
                {
                    //connector.Disconnect();
                    Application.Quit();
                }

                if (GUI.Button(new Rect(160, 25, 120, 20), "Local brocker"))
                {
                    connector = CreateConnector("localhost", 1883, MQTTConnector.DEFAULT_USER, MQTTConnector.DEFAULT_PASSWORD);
                    connector.Subscribe("littosim");
                }

                if (GUI.Button(new Rect(300, 25, 140, 20), "Brocker on vmpams"))
                {
                    connector = CreateConnector(MQTTConnector.SERVER_URL, MQTTConnector.SERVER_PORT, MQTTConnector.DEFAULT_USER, MQTTConnector.DEFAULT_PASSWORD);
                    connector.Subscribe("littosim");
                }

                if (GUI.Button(new Rect(460, 25, 140, 20), "Send Hellow World!"))
                {
                    connector.Publish("test", "Hellow World");
                }

                if (GUI.Button(new Rect(620, 25, 100, 20), "Disconnect"))
                {
                    connector.Disconnect();
                }

                if (GUI.Button(new Rect(820, 25, 200, 20), "Send Message to Gama"))
                {
                    // SendGotBoxMsg();

                    SendReplay("unity", "gama", "test", "field value");
                }
            }
        }
Ejemplo n.º 6
0
        void Start()
        {
            sceneManager = GameObject.Find(IMQTTConnector.SCENE_MANAGER).GetComponent <SceneManager>();

            connector = CreateConnector(MQTTConnector.SERVER_URL, MQTTConnector.SERVER_PORT, MQTTConnector.DEFAULT_USER, MQTTConnector.DEFAULT_PASSWORD);
            connector.Subscribe("littosim");

            agentCreator = GameObject.Find("AgentCreator");

            if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.Equals("LittoSIMInterfaceTabA3"))
            {
                Text txt3 = GameObject.Find("Te3").GetComponent <Text>();
                txt3.text = "  -> CONNECTED From Gama Manager Start " + System.DateTime.Now;
                txt3.text = "  -> MESSAGE SENT From Gama Manager Start " + System.DateTime.Now;
            }
        }
        public async Task <ActionResult> Get(int id)
        {
            var vaga = await MQTTConnector.ReadStorage(id);

            if (vaga.HasValue)
            {
                var json = JObject.FromObject(new
                {
                    vaga = vaga.Value
                });

                return(Ok(json));
            }
            else
            {
                return(BadRequest());
            }
        }