コード例 #1
0
        private CallbackDelegate OnPlaybackEnded(IDictionary <string, object> args, CallbackDelegate callback)
        {
            callback("OK");

            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                return(callback);
            }

            var player = this.videoPlayers?.FirstOrDefault(p => p.PlayerName == screenName);

            if (player == null)
            {
                return(callback);
            }

            this.videoPlayers.Remove(player);
            player.Dispose();

            this.PlaybackEnded.Invoke(screenName);

            return(callback);
        }
コード例 #2
0
        private CallbackDelegate GetStateResponse(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                Debug.WriteLine("Warning: received state response without valid screenName.");
                callback("");
                return(callback);
            }

            var paused        = ArgsReader.GetArgKeyValue <bool>(args, "paused");
            var repeat        = ArgsReader.GetArgKeyValue <bool>(args, "repeat");
            var currentTime   = ArgsReader.GetArgKeyValue <float>(args, "currentTime");
            var duration      = ArgsReader.GetArgKeyValue <float>(args, "duration");
            var ended         = ArgsReader.GetArgKeyValue <bool>(args, "ended");
            var currentSource = ArgsReader.GetArgKeyValue <string>(args, "currentSource");

            var state = new DuiState
            {
                CurrentTime   = currentTime,
                ScreenName    = screenName,
                Ended         = ended,
                IsPaused      = paused,
                Duration      = duration,
                CurrentSource = currentSource,
                Repeat        = repeat
            };

            StateQueue.Enqueue(state);

            callback("OK");
            return(callback);
        }
コード例 #3
0
        private CallbackDelegate OnPlay(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var videoUrl = ArgsReader.GetArgKeyValue <string>(args, "videoUrl");
            var screen   = ArgsReader.GetArgKeyValue <Screen>(args, "screen");

            if (string.IsNullOrEmpty(videoUrl))
            {
                callback("ERROR", "missing videoUrl");
                return(callback);
            }

            if (screen == null)
            {
                callback("ERROR", "missing screen");
                return(callback);
            }

            var playEvent = new PlayEvent()
            {
                Screen = screen, Url = videoUrl
            };

            this.Play.Invoke(playEvent);

            callback("OK");
            return(callback);
        }
コード例 #4
0
        private CallbackDelegate OnSeek(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");
            var time       = ArgsReader.GetArgKeyValue <float>(args, "time");

            this.Seek.Invoke(screenName, time);

            callback("OK");
            return(callback);
        }
コード例 #5
0
        private CallbackDelegate OnPlay(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var videoUrl = ArgsReader.GetArgKeyValue <string>(args, "videoUrl");
            var screen   = ArgsReader.GetArgKeyValue <string>(args, "screen");

            if (!string.IsNullOrEmpty(videoUrl) && !string.IsNullOrEmpty(screen))
            {
                TriggerServerEvent(ServerEvents.OnPlaybackReceived, videoUrl, screen);
            }

            callback("OK");
            return(callback);
        }
コード例 #6
0
        private CallbackDelegate OnVolumeChange(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var volume = ArgsReader.GetArgKeyValue <string>(args, "volume");

            if (string.IsNullOrEmpty(volume))
            {
                return(callback);
            }

            TriggerServerEvent(ServerEvents.OnSetVolume, volume);

            callback("OK");
            return(callback);
        }
コード例 #7
0
        private CallbackDelegate OnToggleRepeat(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                return(callback);
            }

            TriggerServerEvent(ServerEvents.OnToggleRepeat, screenName);

            callback("OK");
            return(callback);
        }
コード例 #8
0
        private CallbackDelegate OnDeleteScreen(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                Debug.WriteLine("screen deletion failed: no screenName provided.");
                return(callback);
            }

            TriggerServerEvent(ServerEvents.OnDeleteScreen, screenName);

            callback("OK");
            return(callback);
        }
コード例 #9
0
        private CallbackDelegate OnDeleteScreen(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                callback("ERROR", "screenName is empty");
                return(callback);
            }

            this.DeleteScreen.Invoke(screenName);

            callback("OK");
            return(callback);
        }
コード例 #10
0
        private CallbackDelegate OnCreateScreen(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screen = ArgsReader.GetArgKeyValue <Screen>(args, "payload");

            if (screen == null)
            {
                callback("ERROR", "payload is empty");
                return(callback);
            }

            this.CreateScreen.Invoke(screen);

            callback("OK");
            return(callback);
        }
コード例 #11
0
        private CallbackDelegate OnUpdateStateDuration(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var duration   = ArgsReader.GetArgKeyValue <float>(args, "duration");
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                callback("ERROR");
                return(callback);
            }

            this.StateDuration.Invoke(screenName, duration);
            callback("OK");
            return(callback);
        }
コード例 #12
0
        private CallbackDelegate OnSeek(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                return(callback);
            }

            var time = ArgsReader.GetArgKeyValue <float>(args, "time");

            this.playerPool.Seek(screenName, time);

            callback("OK");
            return(callback);
        }
コード例 #13
0
        private CallbackDelegate OnEditScreen(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName       = ArgsReader.GetArgKeyValue <string>(args, "screenName");
            var id               = ArgsReader.GetArgKeyValue <int>(args, "id");
            var is3DRendered     = ArgsReader.GetArgKeyValue <bool>(args, "is3DRendered");
            var alwaysOn         = ArgsReader.GetArgKeyValue <bool>(args, "alwaysOn");
            var modelName        = ArgsReader.GetArgKeyValue <string>(args, "modelName");
            var renderTargetName = ArgsReader.GetArgKeyValue <string>(args, "renderTargetName");
            var globalVolume     = ArgsReader.GetArgKeyValue <float>(args, "globalVolume", 100f);
            var soundAttenuation = ArgsReader.GetArgKeyValue <float>(args, "soundAttenuation", 5f);
            var soundMinDistance = ArgsReader.GetArgKeyValue <float>(args, "soundMinDistance", 15f);
            var soundMaxDistance = ArgsReader.GetArgKeyValue <float>(args, "soundMaxDistance", 100f);
            var positionX        = ArgsReader.GetArgKeyValue <float>(args, "positionX");
            var positionY        = ArgsReader.GetArgKeyValue <float>(args, "positionY");
            var positionZ        = ArgsReader.GetArgKeyValue <float>(args, "positionZ");
            var rotationX        = ArgsReader.GetArgKeyValue <float>(args, "rotationX");
            var rotationY        = ArgsReader.GetArgKeyValue <float>(args, "rotationY");
            var rotationZ        = ArgsReader.GetArgKeyValue <float>(args, "rotationZ");
            var scaleX           = ArgsReader.GetArgKeyValue <float>(args, "scaleX");
            var scaleY           = ArgsReader.GetArgKeyValue <float>(args, "scaleY");
            var scaleZ           = ArgsReader.GetArgKeyValue <float>(args, "scaleZ");
            var is3DAudioEnabled = ArgsReader.GetArgKeyValue <bool>(args, "is3DAudioEnabled");

            var screen = new Screen
            {
                Id              = id,
                Name            = screenName,
                AlwaysOn        = alwaysOn,
                Is3DRendered    = is3DRendered,
                BrowserSettings =
                    new DuiBrowserSettings
                {
                    GlobalVolume     = globalVolume,
                    SoundMaxDistance = soundMaxDistance,
                    SoundAttenuation = soundAttenuation,
                    SoundMinDistance = soundMinDistance,
                    Is3DAudioEnabled = is3DAudioEnabled
                },
                TargetSettings =
                    is3DRendered
                                         ? null
                                         : new RenderTargetSettings
                {
                    ModelName = modelName, RenderTargetName = renderTargetName
                },
                PositionalSettings = is3DRendered
                                                          ? new PositionalSettings
                {
                    PositionX = positionX,
                    PositionY = positionY,
                    PositionZ = positionZ,
                    RotationX = rotationX,
                    RotationY = rotationY,
                    RotationZ = rotationZ,
                    ScaleX    = scaleX,
                    ScaleY    = scaleY,
                    ScaleZ    = scaleZ
                }
                                                          : null
            };

            TriggerServerEvent(ServerEvents.OnEditScreen, JsonConvert.SerializeObject(screen));

            callback("OK");
            return(callback);
        }
コード例 #14
0
        private CallbackDelegate OnCreateScreen(IDictionary <string, object> args, CallbackDelegate callback)
        {
            var screenName = ArgsReader.GetArgKeyValue <string>(args, "screenName");

            if (string.IsNullOrEmpty(screenName))
            {
                Debug.WriteLine("failed to create screen: screenName is missing");
                return(callback);
            }

            var is3DRendered     = ArgsReader.GetArgKeyValue <bool>(args, "is3DRendered");
            var alwaysOn         = ArgsReader.GetArgKeyValue <bool>(args, "alwaysOn");
            var modelName        = ArgsReader.GetArgKeyValue <string>(args, "modelName");
            var renderTargetName = ArgsReader.GetArgKeyValue <string>(args, "renderTargetName");
            var positionX        = ArgsReader.GetArgKeyValue <float>(args, "positionX");
            var positionY        = ArgsReader.GetArgKeyValue <float>(args, "positionY");
            var positionZ        = ArgsReader.GetArgKeyValue <float>(args, "positionZ");
            var rotationX        = ArgsReader.GetArgKeyValue <float>(args, "rotationX");
            var rotationY        = ArgsReader.GetArgKeyValue <float>(args, "rotationY");
            var rotationZ        = ArgsReader.GetArgKeyValue <float>(args, "rotationZ");
            var scaleX           = ArgsReader.GetArgKeyValue <float>(args, "scaleX");
            var scaleY           = ArgsReader.GetArgKeyValue <float>(args, "scaleY");
            var scaleZ           = ArgsReader.GetArgKeyValue <float>(args, "scaleZ");
            var globalVolume     = ArgsReader.GetArgKeyValue(args, "globalVolume", 100f);
            var soundAttenuation = ArgsReader.GetArgKeyValue <float>(args, "soundAttenuation", 5f);
            var soundMinDistance = ArgsReader.GetArgKeyValue <float>(args, "soundMinDistance", 15f);
            var soundMaxDistance = ArgsReader.GetArgKeyValue <float>(args, "soundMaxDistance", 100f);
            var is3DAudioEnabled = ArgsReader.GetArgKeyValue <bool>(args, "is3DAudioEnabled");

            var screen = new Screen
            {
                AlwaysOn        = alwaysOn,
                Name            = screenName,
                Is3DRendered    = is3DRendered,
                BrowserSettings =
                    new DuiBrowserSettings
                {
                    GlobalVolume     = globalVolume,
                    SoundMaxDistance = soundMaxDistance,
                    SoundMinDistance = soundMinDistance,
                    SoundAttenuation = soundAttenuation,
                    Is3DAudioEnabled = is3DAudioEnabled
                },
                PositionalSettings = is3DRendered
                                                          ? new PositionalSettings
                {
                    PositionX = positionX,
                    PositionY = positionY,
                    PositionZ = positionZ,
                    RotationX = rotationX,
                    RotationY = rotationY,
                    RotationZ = rotationZ,
                    ScaleX    = scaleX,
                    ScaleY    = scaleY,
                    ScaleZ    = scaleZ
                }
                                                          : null,
                TargetSettings = is3DRendered
                                                      ? null
                                                      : new RenderTargetSettings
                {
                    ModelName        = modelName,
                    RenderTargetName = renderTargetName
                }
            };

            // TODO: IsAceAllowed() to reduce server load
            TriggerServerEvent(ServerEvents.OnCreateScreen, JsonConvert.SerializeObject(screen));

            callback("OK");
            return(callback);
        }