Example #1
0
    /// <summary>
    /// Sends messages to the realtime feed.
    /// </summary>
    /// <param name="messages">The messages to send.</param>
    public static void Record(string[] messages)
    {
        if (!Lumos.servicesAvailable.Contains(Lumos.service.Realtime))
        {
            return;
        }

        if (messages.Length == 0)
        {
            return;
        }

        var encodedMessages = new List <string>();

        foreach (var message in messages)
        {
            var encoded = new Dictionary <string, string>()
            {
                { "level", Application.loadedLevelName },
                { "message", message }
            };

            var json = LumosUtil.Json.Serialize(encoded);
            encodedMessages.Add(json);
        }

        var parameters = new Dictionary <string, object>()
        {
            { "messages", encodedMessages }
        };

        LumosWWW.Send("realtime.message", parameters);
    }
Example #2
0
    /// <summary>
    /// Notifies the server that the player is playing.
    /// </summary>
    /// <param name="sendPlayerInfo">Whether to send info about the player.</param>
    public static void Ping(bool sendPlayerInfo)
    {
        var parameters = new Dictionary <string, object>()
        {
            { "player_id", Lumos.playerId },
            { "lumos_version", Lumos.version.ToString() }
        };

        if (sendPlayerInfo)
        {
            var playerInfo = new Dictionary <string, object>()
            {
                { "language", Application.systemLanguage.ToString() }
            };

            // Report the domain if the game's deployed on the web
            if (Application.isWebPlayer)
            {
                playerInfo.Add("domain", Application.absoluteURL);
            }

            parameters.Add("player_info", playerInfo);
        }

        LumosWWW.Send("app.ping", parameters);
    }
    /// <summary>
    /// Sends system information.
    /// </summary>
    public static void Record()
    {
        if (!Lumos.servicesAvailable.Contains(Lumos.service.SystemInfo)) {
            return;
        }

        if (Application.platform == RuntimePlatform.IPhonePlayer) {
            Debug.LogWarning("[Lumos] Apple's Terms of Service disallows " +
                             " recording device data on iOS. " +
                             "As such, system info will not be recorded.");
            return;
        }

        var parameters = new Dictionary<string, object>() {
            { "player_id", Lumos.playerId },
            { "operating_system", SystemInfo.operatingSystem },
            { "processor_type", SystemInfo.processorType },
            { "processor_count", SystemInfo.processorCount },
            { "system_memory_size", SystemInfo.systemMemorySize },
            { "graphics_memory_size", SystemInfo.graphicsMemorySize },
            { "graphics_device_name", SystemInfo.graphicsDeviceName },
            { "graphics_device_vendor", SystemInfo.graphicsDeviceVendor },
            { "graphics_device_id", SystemInfo.graphicsDeviceID },
            { "graphics_device_vendor_id", SystemInfo.graphicsDeviceVendorID },
            { "graphics_device_version", SystemInfo.graphicsDeviceVersion },
            { "graphics_shader_level", SystemInfo.graphicsShaderLevel },
            { "graphics_pixel_fillrate", SystemInfo.graphicsPixelFillrate },
            { "supports_shadows", SystemInfo.supportsShadows },
            { "supports_render_textures", SystemInfo.supportsRenderTextures },
            { "supports_image_effects", SystemInfo.supportsImageEffects }
        };

        LumosWWW.Send("system-info.record", parameters);
    }
    /// <summary>
    /// Sends system information.
    /// </summary>
    public static void Record()
    {
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            Lumos.LogWarning("Apple's ToS prevents device data from being sent on iOS");
            return;
        }

        var parameters = new Dictionary <string, object>()
        {
            { "player_id", Lumos.playerId },
            { "operating_system", SystemInfo.operatingSystem },
            { "processor_type", SystemInfo.processorType },
            { "processor_count", SystemInfo.processorCount },
            { "system_memory_size", SystemInfo.systemMemorySize },
            { "graphics_memory_size", SystemInfo.graphicsMemorySize },
            { "graphics_device_name", SystemInfo.graphicsDeviceName },
            { "graphics_device_vendor", SystemInfo.graphicsDeviceVendor },
            { "graphics_device_id", SystemInfo.graphicsDeviceID },
            { "graphics_device_vendor_id", SystemInfo.graphicsDeviceVendorID },
            { "graphics_device_version", SystemInfo.graphicsDeviceVersion },
            { "graphics_shader_level", SystemInfo.graphicsShaderLevel },
            { "graphics_pixel_fillrate", SystemInfo.graphicsPixelFillrate },
            { "supports_shadows", SystemInfo.supportsShadows },
            { "supports_render_textures", SystemInfo.supportsRenderTextures },
            { "supports_image_effects", SystemInfo.supportsImageEffects }
        };

        LumosWWW.Send("system-info.record", parameters);
    }
Example #5
0
    /// <summary>
    /// Records a message and sends it immediately.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <param name="email">The player's email address.</param>
    /// <param name="type">The category of feedback.</param>
    public static void Record(string message, string email, string type)
    {
        if (!Lumos.servicesAvailable.Contains(Lumos.service.Feedback))
        {
            return;
        }

        var parameters = new Dictionary <string, object>()
        {
            { "player_id", Lumos.playerId },
            { "message", message }
        };

        if (email != null)
        {
            parameters.Add("email", email);
        }

        if (type != null)
        {
            parameters.Add("type", type);
        }

        LumosWWW.Send("feedback.record", parameters);
    }
Example #6
0
    /// <summary>
    /// Sends the queued logs to the server.
    /// </summary>
    public static void Send()
    {
        if (logs.Count == 0)
        {
            return;
        }

        var parameters = new Dictionary <string, object>()
        {
            { "logs", logs }
        };

        LumosWWW.Send("logs.record", parameters,
                      delegate {   // Success
            logs.Clear();
        },
                      delegate {   // Error
            Lumos.LogWarning("Log messages not sent. Will try again at next timer interval.");
        });
    }
Example #7
0
    /// <summary>
    /// Records a message and sends it immediately.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <param name="email">The player's email address.</param>
    /// <param name="type">The category of feedback.</param>
    public static void Record(string message, string email, string type)
    {
        var parameters = new Dictionary <string, object>()
        {
            { "player_id", Lumos.playerId },
            { "message", message }
        };

        if (email != null)
        {
            parameters.Add("email", email);
        }

        if (type != null)
        {
            parameters.Add("type", type);
        }

        LumosWWW.Send("feedback.record", parameters);
    }
Example #8
0
    /// <summary>
    /// Sends the events.
    /// </summary>
    public static void Send()
    {
        if (events.Count == 0)
        {
            return;
        }

        var parameters = new Dictionary <string, object>()
        {
            { "events", events }
        };

        LumosWWW.Send("events.record", parameters, delegate {
            // Save unrepeatable events to player prefs with a timestamp
            foreach (var eventName in unsentUniqueEvents)
            {
                PlayerPrefs.SetString(PlayerPrefsKey(eventName), System.DateTime.Now.ToString());
            }

            unsentUniqueEvents.Clear();
            events.Clear();
        });
    }
    /// <summary>
    /// Notifies the server that the player is playing.
    /// </summary>
    /// <param name="sendPlayerInfo">Whether to send player info.</param>
    public static void Ping(bool sendPlayerInfo)
    {
        var parameters = new Dictionary <string, object>()
        {
            { "player_id", Lumos.playerId },
            { "lumos_version", Lumos.version.ToString() }
        };

        if (sendPlayerInfo)
        {
            // Attach extra information about the player.
            var playerInfo = new Dictionary <string, object>()
            {
                { "language", Application.systemLanguage.ToString() }
            };

            // Report the domain if the game is deployed on the web.
            if (Application.isWebPlayer)
            {
                playerInfo.Add("domain", Application.absoluteURL);
            }

            parameters.Add("player_info", playerInfo);
        }

        LumosWWW.Send("app.ping", parameters, delegate {
            // Parse which services are available.
            var response = LumosWWW.lastResponse;

            if (!response.Contains("services_available"))
            {
                Lumos.Remove("Available services unknown.");
                return;
            }

            var servicesAvailable = response["services_available"] as IList;

            if (servicesAvailable.Contains("none"))
            {
                Lumos.Remove("No services available. " +
                             "The game is either over quota or nonexistant.");
                return;
            }

            foreach (string service in servicesAvailable)
            {
                if (service == "system-info")
                {
                    Lumos.servicesAvailable.Add(Lumos.service.SystemInfo);
                }
                else if (service == "events")
                {
                    Lumos.servicesAvailable.Add(Lumos.service.Events);
                }
                else if (service == "logs")
                {
                    Lumos.servicesAvailable.Add(Lumos.service.Logs);
                }
                else if (service == "feedback")
                {
                    Lumos.servicesAvailable.Add(Lumos.service.Feedback);
                }
                else if (service == "realtime")
                {
                    Lumos.servicesAvailable.Add(Lumos.service.Realtime);
                }
            }

            if (sendPlayerInfo)
            {
                LumosSystemInfo.Record();
            }
        });
    }