Exemplo n.º 1
0
        /// <summary>
        /// Creates a seek.
        /// </summary>
        /// <param name="time">The time.</param>
        /// <param name="increment">The increment.</param>
        /// <param name="ratingLow">The rating low.</param>
        /// <param name="ratingHigh">The rating high.</param>
        /// <returns></returns>
        public async Task <SeekResponse> CreateSeek(int time, int increment, int ratingLow, int ratingHigh)
        {
            //TODO: Change for anonymous player requests

            LilaRequest setupSeek = new LilaRequest(new Uri(string.Format("/setup/hook/{0}", LobbySri), UriKind.Relative));

            setupSeek.Cookies.Add(lobbyCon.GetCookies());

            double timeMinutes = time / 60000.0;
            string ratingRange = string.Format("{0}-{1}", ratingLow, ratingHigh);

            string[] keys   = new string[] { "variant", "timeMode", "time", "increment", "days", "mode", "ratingRange", "color" };
            object[] values = new object[] { 1, 1, timeMinutes, increment, 2, 1, ratingRange, "white" };

            LilaResponse res = await setupSeek.Post(LilaRequest.ContentType.Any, keys, values);

            if (res == null || !res.CheckStatus(HttpStatusCode.OK | HttpStatusCode.SeeOther))
            {
                return(null);
            }

            SeekResponse sr = res.ReadJson <SeekResponse>();

            return(sr);
        }
Exemplo n.º 2
0
        public AResponse CreateResponse(string responseData)
        {
            AResponse response = null;

            try
            {
                // validate length
                if (responseData.Length < Protocol.Instance.HeaderLength)
                {
                    throw new ParserException("invalid responseData length");
                }

                // get the header
                string header = responseData.Substring(0, (int)Protocol.Instance.HeaderLength);

                switch (_messageHeaderMapper[header])
                {
                case MessageType.DisplayDevicesInfo:
                    response = new DisplayDeviceInfoResponse();
                    break;

                case MessageType.Pause:
                    response = new PauseResponse();
                    break;

                case MessageType.Play:
                    response = new PlayResponse();
                    break;

                case MessageType.Resume:
                    response = new ResumeResponse();
                    break;

                case MessageType.Seek:
                    response = new SeekResponse();
                    break;

                case MessageType.SetImage:
                    response = new SetImageResponse();
                    break;

                case MessageType.SetText:
                    response = new SetTextResponse();
                    break;

                case MessageType.RemoveAddon:
                    response = new RemoveAddonResponse();
                    break;

                case MessageType.Stop:
                    response = new StopResponse();
                    break;

                case MessageType.Termination:
                    response = new TerminationResponse();
                    break;

                case MessageType.VideoLayout:
                    response = new VideoLayoutResponse();
                    break;

                case MessageType.Volume:
                    response = new VolumeResponse();
                    break;

                case MessageType.WindowLayout:
                    response = new WindowLayoutResponse();
                    break;

                case MessageType.SoundFx:
                    response = new SoundFxResponse();
                    break;

                case MessageType.Sound3d:
                    response = new Sound3dResponse();
                    break;

                case MessageType.MidiProperties:
                    response = new MidiPropertiesResponse();
                    break;

                case MessageType.MidiOutputPortInfo:
                    response = new MidiOutputPortInfoResponse();
                    break;

                case MessageType.SetMidiOutputPort:
                    response = new SetMidiOutputPortResponse();
                    break;

                case MessageType.SetDls:
                    response = new SetDlsResponse();
                    break;

                case MessageType.SetFrequency:
                    response = new SetFrequencyResponse();
                    break;

                case MessageType.SetRate:
                    response = new SetRateResponse();
                    break;

                case MessageType.SetPlayerType:
                    response = new SetPlayerTypeResponse();
                    break;

                default:
                    throw new ParserException("invalid message header");
                }
                response.ParseFromString(responseData);
            }
            catch (System.Exception e)
            {
                throw e;
            }

            return(response);
        }