public void sendEvent(TrackingEvent trackingEvent, CustomData customData = null, string section = null, int[] coordinates = null)
 {
     //logMessage("RedMetricsManager::sendEvent");
     if (Application.isWebPlayer)
     {
         TrackingEventDataWithoutIDs data = new TrackingEventDataWithoutIDs(trackingEvent, customData, section, coordinates);
         string json = getJsonString(data);
         //logMessage("RedMetricsManager::sendEvent isWebPlayer will rmPostEvent json="+json);
         Application.ExternalCall("rmPostEvent", json);
     }
     else
     {
         //logMessage("RedMetricsManager::sendEvent non web player");
         //TODO wait on playerID using an IEnumerator
         if (!string.IsNullOrEmpty(playerID))
         {
             TrackingEventDataWithIDs data = new TrackingEventDataWithIDs(playerID, gameVersion, trackingEvent, customData, section, coordinates);
             string json = getJsonString(data);
             //logMessage("RedMetricsManager::sendEvent player already identified - pID="+playerID);
             sendDataStandalone(redMetricsEvent, json, value => wwwLogger(value, "sendEvent(" + trackingEvent + ")"));
         }
         else
         {
             logMessage("RedMetricsManager::sendEvent no registered player!", MessageLevel.ERROR);
         }
     }
 }
Exemple #2
0
    public void sendEvent(TrackingEvent trackingEvent, CustomData customData = null, string section = null, int[] coordinates = null, string userTime = null)
    {
        string checkedSection = section;

        //TODO remove dependency to Hero class
        if (string.IsNullOrEmpty(section) && (null != Hero.get()))
        {
            checkedSection = Hero.get().getLastCheckpointName();
        }

        int[] checkedCoordinates = null;
        if (null != coordinates)
        {
            checkedCoordinates = new int[coordinates.Length];
            for (int i = 0; i < coordinates.Length; i++)
            {
                checkedCoordinates [i] = coordinates [i];
            }
        }
        else
        {
            if (null != Hero.get())
            {
                Vector3 position = Hero.get().gameObject.transform.position;
                checkedCoordinates = new int[2] {
                    Mathf.FloorToInt(position.x),
                    Mathf.FloorToInt(position.z)
                };
            }
        }

        //logMessage(MessageLevel.DEFAULT, "RedMetricsManager::sendEvent({0})", trackingEvent.ToString());
        if (Application.isWebPlayer)
        {
            TrackingEventDataWithoutIDs data = new TrackingEventDataWithoutIDs(trackingEvent, customData, checkedSection, checkedCoordinates, userTime);
            if (isGameSessionGUIDCreated)
            {
                string json = getJsonString(data);
                Application.ExternalCall("rmPostEvent", json);
            }
            else
            {
                addEventToSendLater(data);
                //TODO: what if connection fails, or even fails permanently? Should retry connection at different intervals
            }
        }
        else
        {
            //TODO wait on gameSessionGUID using an IEnumerator
            if (defaultGameSessionGUID != gameSessionGUID)
            {
            }
            else
            {
                logMessage(MessageLevel.ERROR, "sendEvent default player guid: no registered player!");
            }

            TrackingEventDataWithIDs data = new TrackingEventDataWithIDs(gameSessionGUID, gameVersionGuid, trackingEvent, customData, checkedSection, checkedCoordinates);
            string json = getJsonString(data);
            //logMessage (MessageLevel.DEFAULT, string.Format ("RedMetricsManager::sendEvent - gameSessionGUID={0}, gameVersionGuid={1}, json={2}", gameSessionGUID, gameVersionGuid, json));
            sendDataStandalone(redMetricsEvent, json, value => wwwLogger(value, "sendEvent(" + trackingEvent + ")"));
            //TODO pass data as parameter to sendDataStandalone so that it's serialized inside
        }
    }
 public void sendEvent(TrackingEvent trackingEvent, CustomData customData = null, string section = null, int[] coordinates = null)
 {
     //logMessage("RedMetricsManager::sendEvent");
     if(Application.isWebPlayer) {
         TrackingEventDataWithoutIDs data = new TrackingEventDataWithoutIDs(trackingEvent, customData, section, coordinates);
         string json = getJsonString(data);
         //logMessage("RedMetricsManager::sendEvent isWebPlayer will rmPostEvent json="+json);
         Application.ExternalCall("rmPostEvent", json);
     } else {
         //logMessage("RedMetricsManager::sendEvent non web player");
         //TODO wait on playerID using an IEnumerator
         if(!string.IsNullOrEmpty(playerID))
         {
             TrackingEventDataWithIDs data = new TrackingEventDataWithIDs(playerID, gameVersion, trackingEvent, customData, section, coordinates);
             string json = getJsonString(data);
             //logMessage("RedMetricsManager::sendEvent player already identified - pID="+playerID);
             sendDataStandalone(redMetricsEvent, json, value => wwwLogger(value, "sendEvent("+trackingEvent+")"));
         } else {
             logMessage("RedMetricsManager::sendEvent no registered player!", MessageLevel.ERROR);
         }
     }
 }
    public void sendEvent (TrackingEvent trackingEvent, CustomData customData = null, string section = null, int[] coordinates = null, string userTime = null)
    {
        string checkedSection = section;

        //TODO remove dependency to Hero class
        if (string.IsNullOrEmpty (section) && (null != Hero.get ())) {
            checkedSection = Hero.get ().getLastCheckpointName ();
        }

        int[] checkedCoordinates = null;
        if (null != coordinates) {
            checkedCoordinates = new int[coordinates.Length];
            for (int i = 0; i < coordinates.Length; i++) {
                checkedCoordinates [i] = coordinates [i];
            }
        } else {
            if (null != Hero.get ()) {
                Vector3 position = Hero.get ().gameObject.transform.position;
                checkedCoordinates = new int[2] {
                    Mathf.FloorToInt (position.x),
                    Mathf.FloorToInt (position.z)
                };
            }
        }
             
        //logMessage(MessageLevel.DEFAULT, "RedMetricsManager::sendEvent({0})", trackingEvent.ToString());
        if (Application.isWebPlayer) {
            TrackingEventDataWithoutIDs data = new TrackingEventDataWithoutIDs (trackingEvent, customData, checkedSection, checkedCoordinates, userTime);   
            if(isGameSessionGUIDCreated) {
                string json = getJsonString (data);
                Application.ExternalCall ("rmPostEvent", json);
            } else {
                addEventToSendLater(data);
                //TODO: what if connection fails, or even fails permanently? Should retry connection at different intervals
            }
        } else {
            //TODO wait on gameSessionGUID using an IEnumerator
            if (defaultGameSessionGUID != gameSessionGUID) {
            } else {
                logMessage (MessageLevel.ERROR, "sendEvent default player guid: no registered player!");
            }

            TrackingEventDataWithIDs data = new TrackingEventDataWithIDs (gameSessionGUID, gameVersionGuid, trackingEvent, customData, checkedSection, checkedCoordinates);
            string json = getJsonString (data);
            //logMessage (MessageLevel.DEFAULT, string.Format ("RedMetricsManager::sendEvent - gameSessionGUID={0}, gameVersionGuid={1}, json={2}", gameSessionGUID, gameVersionGuid, json));
            sendDataStandalone (redMetricsEvent, json, value => wwwLogger (value, "sendEvent(" + trackingEvent + ")"));
            //TODO pass data as parameter to sendDataStandalone so that it's serialized inside
        }
    }