예제 #1
0
    private void OnChat(ChatData data)
    {
        // Try to parse the message as a chat command and ignore it if it is not a known command
        var tokens = data.Message.Split(new char[] { ' ' });

        if (CheckCommand(tokens, CommandAgentMediaUrl, 2))
        {
            string       url   = tokens[1];
            AgentPrivate agent = ScenePrivate.FindAgent(data.SourceId);
            agent.OverrideMediaSource(url);
        }
        else if (CheckCommand(tokens, CommandAgentMediaSizeAndUrl, 4))
        {
            Int32        width  = Int32.Parse(tokens[1]);
            Int32        height = Int32.Parse(tokens[2]);
            string       url    = tokens[3];
            AgentPrivate agent  = ScenePrivate.FindAgent(data.SourceId);
            agent.OverrideMediaSource(url, width, height);
        }
        else if (CheckCommand(tokens, CommandSceneMediaUrl, 2))
        {
            string url = tokens[1];
            ScenePrivate.OverrideMediaSource(url);
        }
        else if (CheckCommand(tokens, CommandSceneMediaSizeAndUrl, 4))
        {
            Int32  width  = Int32.Parse(tokens[1]);
            Int32  height = Int32.Parse(tokens[2]);
            string url    = tokens[3];
            ScenePrivate.OverrideMediaSource(url, width, height);
        }
    }
예제 #2
0
        void SubscribeToMessages()
        {
            // Already subscribed
            if (unsubscribes != null)
            {
                return;
            }

            foreach (var kvp in mediaUrls)
            {
                unsubscribes += SubscribeToAll(kvp.Key, (ScriptEventData subData) =>
                {
                    if (PrivateMedia)
                    {
                        ISimpleData simpleData = subData.Data?.AsInterface <ISimpleData>();

                        if (simpleData != null && simpleData.AgentInfo != null)
                        {
                            AgentPrivate agent = ScenePrivate.FindAgent(simpleData.AgentInfo.SessionId);

                            if (agent != null && agent.IsValid)
                            {
                                try
                                {
                                    agent.OverrideMediaSource(kvp.Value, MediaWidth, MediaHeight);
                                }
                                catch (ThrottleException)
                                {
                                    // Throttled
                                    Log.Write(LogLevel.Warning, "OverrideMediaSource request throttle hit. Media not set.");
                                }
                                catch (NullReferenceException)
                                {
                                    // User Left, ignore.
                                }
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            ScenePrivate.OverrideMediaSource(kvp.Value, MediaWidth, MediaHeight);
                        }
                        catch (ThrottleException)
                        {
                            // Throttled
                            Log.Write(LogLevel.Warning, "OverrideMediaSource request throttle hit. Media not set.");
                        }
                    }
                });
            }
        }
예제 #3
0
    public override void Init()
    {
        // Set the public media source for the scene
        ScenePrivate.OverrideMediaSource(PublicMedia);

        // Override the media source to the private media source for each user that clicks on this object

        ObjectPrivate.AddInteractionData addData = (ObjectPrivate.AddInteractionData)WaitFor(ObjectPrivate.AddInteraction, "Show media", true);

        addData.Interaction.Subscribe((InteractionData data) =>
        {
            AgentPrivate agent = ScenePrivate.FindAgent(data.AgentId);

            if (agent != null)
            {
                agent.OverrideMediaSource(PrivateMedia);
            }
        });
    }