public String CreateAugmentaMessageJSON(AugmentaMessageType messageType, GameObject obj = null) { switch (messageType) { case AugmentaMessageType.AugmentaObjectEnter: return("{\n\"object\": {\n\"enter\": " + CreateAugmentaMessageJSONData(obj) + "\n}\n}"); case AugmentaMessageType.AugmentaObjectUpdate: return("{\n\"object\": {\n\"update\": " + CreateAugmentaMessageJSONData(obj) + "\n}\n}"); case AugmentaMessageType.AugmentaObjectLeave: return("{\n\"object\": {\n\"leave\": " + CreateAugmentaMessageJSONData(obj) + "\n}\n}"); case AugmentaMessageType.SceneUpdated: return(CreateAugmentaMessageJSONScene()); default: Debug.Log("Unsupported message type " + messageType.ToString()); return(String.Empty); } }
/// <summary> /// Send an Augmenta OSC message /// </summary> /// <param name="messageType"></param> /// <param name="obj"></param> public void SendAugmentaMessage(AugmentaMessageType messageType, GameObject obj = null) { if (mute) { return; } // Craft and send a message that contains the event + extra info WebsocketManager.activeManager.SendAugmentaMessage(CreateAugmentaMessageJSON(messageType, obj)); switch (ProtocolVersionManager.protocolVersion) { case ProtocolVersionManager.AugmentaProtocolVersion.V1: OSCManager.activeManager.SendAugmentaMessage(CreateAugmentaMessageV1(messageType, obj)); break; case ProtocolVersionManager.AugmentaProtocolVersion.V2: OSCManager.activeManager.SendAugmentaMessage(CreateAugmentaMessageV2(messageType, obj)); if (messageType != AugmentaMessageType.SceneUpdated) { //Send corresponding /extra message OSCManager.activeManager.SendAugmentaMessage(CreateAugmentaMessageV2((AugmentaMessageType)Enum.Parse(typeof(AugmentaMessageType), messageType.ToString() + "Extra"), obj)); } break; } }