mqttdatabase
This commit is contained in:
@@ -15,11 +15,6 @@ namespace Octopus.Simulator
|
||||
[Serializable]
|
||||
public class BaseSimulationMessage
|
||||
{
|
||||
public string type;
|
||||
public string _event;
|
||||
public string component_type;
|
||||
public string component_id;
|
||||
//public List<string> data;
|
||||
public string timestamp;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace Octopus.Simulator
|
||||
[Serializable]
|
||||
public class SimulatorPostClass
|
||||
{
|
||||
public int status=null;
|
||||
public int status;
|
||||
public string code;
|
||||
public string message;
|
||||
public SimulationData data = new SimulationData();
|
||||
|
||||
28
Assets/WorkSpace/LH/MQTTDataBase.cs
Normal file
28
Assets/WorkSpace/LH/MQTTDataBase.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class MQTTDataBase : MonoBehaviour
|
||||
{
|
||||
public static MQTTDataBase Instance;
|
||||
public Dictionary<string,List<string>> mqttDataBase;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
mqttDataBase = new Dictionary<string, List<string>>();
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void AddDict(string key, string value)
|
||||
{
|
||||
if (mqttDataBase.ContainsKey(key))
|
||||
{
|
||||
mqttDataBase[key].Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
var values = new List<string>();
|
||||
values.Add(value);
|
||||
mqttDataBase.Add(key, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/WorkSpace/LH/MQTTDataBase.cs.meta
Normal file
2
Assets/WorkSpace/LH/MQTTDataBase.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edf9e532e5ff77f47bc99037340faf31
|
||||
@@ -115,8 +115,12 @@ namespace Octopus.Simulator.Networks
|
||||
private void OnMessage(MQTTClient client, SubscriptionTopic topic, string topicName, ApplicationMessage message)
|
||||
{
|
||||
var payload = Encoding.UTF8.GetString(message.Payload.Data, message.Payload.Offset, message.Payload.Count);
|
||||
Debug.Log(payload);
|
||||
//basemessage = JsonConvert.DeserializeObject<BaseSimulationMessage>(payload);
|
||||
//Debug.Log(payload);
|
||||
if (payload.Contains("_event"))
|
||||
{
|
||||
basemessage = JsonConvert.DeserializeObject<BaseSimulationMessage>(payload);
|
||||
MQTTDataBase.Instance.AddDict(basemessage._event, payload);
|
||||
}
|
||||
//onMessageReceived?.Invoke(topicName, payload);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ GameObject:
|
||||
- component: {fileID: 1756997497928447498}
|
||||
- component: {fileID: 8164125700257988699}
|
||||
- component: {fileID: 6191105916327120908}
|
||||
- component: {fileID: 8343195631698366838}
|
||||
m_Layer: 0
|
||||
m_Name: NetworkManager
|
||||
m_TagString: Untagged
|
||||
@@ -47,11 +48,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basemessage:
|
||||
type:
|
||||
_event:
|
||||
component_type:
|
||||
component_id:
|
||||
timestamp:
|
||||
MQTTpath: /MQTTConfig.json
|
||||
_topic:
|
||||
--- !u!114 &8164125700257988699
|
||||
@@ -117,6 +114,18 @@ MonoBehaviour:
|
||||
references:
|
||||
version: 2
|
||||
RefIds: []
|
||||
--- !u!114 &8343195631698366838
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1392524223077930677}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: edf9e532e5ff77f47bc99037340faf31, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &2069922514250663687
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
Reference in New Issue
Block a user