Beispiel #1
0
        public void SendMessage(string text)
        {
            if (Name == null)
            {
                if (text.StartsWith("/w "))
                {
                    var channel = AllChannels.FirstOrDefault();

                    if (channel != null)
                    {
                        //IrcManager.Client.Say(text, "fivetf", true);
                        IrcManager.SendMessage(channel, text, IsModOrBroadcaster);
                    }
                }

                return;
            }

            IrcManager.SendMessage(this, text, IsModOrBroadcaster);

            if (AppSettings.Rainbow)
            {
                usernameHue += 0.1f;

                float r, g, b;
                (new HSLColor(usernameHue % 1, 0.5f, 0.5f)).ToRGB(out r, out g, out b);

                IrcManager.SendMessage(this, $".color #{(int)(r * 255):X}{(int)(g * 255):X}{(int)(b * 255):X}", IsModOrBroadcaster);
            }
        }
Beispiel #2
0
    /// <summary>
    /// Watch the live channel on the specified number
    /// </summary>
    /// <param name="internalNumber"></param>
    public void ChangeChannel(
        int internalNumber)
    {
        if (internalNumber == 0)
        {
            internalNumber = AllChannels.First().Key;
        }

        //  Post to SkyPlay
        string postData = String.Format(
            @"<?xml version='1.0' encoding='utf-8'?>
<s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
    <s:Body>
        <u:SetAVTransportURI xmlns:u='urn:schemas-nds-com:service:SkyPlay:2'>
            <InstanceID>0</InstanceID>
            <CurrentURI>xsi://{0:X}</CurrentURI>
            <CurrentURIMetaData>NOT_IMPLEMENTED</CurrentURIMetaData>
        </u:SetAVTransportURI>
    </s:Body>
</s:Envelope>", internalNumber);

        try
        {
            SkyPlay(null, "urn:schemas-nds-com:service:SkyPlay:2#SetAVTransportURI", postData, 1000);
            System.Threading.Thread.Sleep(1000);
            GetCurrentChannelInfo();
        }
        catch (Exception)
        {
        }
    }
Beispiel #3
0
 public Recording(
     XElement xRecording)
 {
     try
     {
         Id          = xRecording.Attribute("id").Value;
         Title       = xRecording.Element("title").Value;
         Description = xRecording.Element("info").Value;
         Channel     = AllChannels.FirstOrDefault(c => c.Name.Equals(xRecording.Element("channel").Value, StringComparison.CurrentCultureIgnoreCase));
         StartTime   = DateTime.ParseExact(
             xRecording.Attribute("start").Value,
             new[] { "yyyyMMddHHmmss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
         Duration = TimeSpan.ParseExact(xRecording.Attribute("duration").Value,
                                        "hhmmss",
                                        CultureInfo.InvariantCulture);
         Filename = xRecording.Element("file").Value;
         InError  = false;
     }
     catch (System.Exception ex)
     {
         logger.Error(ex, "Error parsing Recording XML");
         InError = true;
     }
 }
Beispiel #4
0
 public Timer(
     XElement xTimer)
 {
     try
     {
         Id        = xTimer.Element("ID").Value;
         Name      = xTimer.Element("Descr").Value;
         PrePad    = xTimer.Attribute("PreEPG") == null ? TimeSpan.Zero : TimeSpan.FromMinutes(int.Parse(xTimer.Attribute("PreEPG").Value));
         PostPad   = xTimer.Attribute("PostEPG") == null ? TimeSpan.Zero : TimeSpan.FromMinutes(int.Parse(xTimer.Attribute("PostEPG").Value));
         Channel   = AllChannels.FirstOrDefault(c => c.Name == xTimer.Element("Channel").Attribute("ID").Value.Split('|')[1]);
         StartTime = DateTime.ParseExact(
             xTimer.Attribute("Date").Value + " " + xTimer.Attribute("Start").Value,
             new[] { "dd.MM.yyyy HH:mm:ss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal) + PrePad;
         StopTime    = StartTime.AddMinutes(int.Parse(xTimer.Attribute("Dur").Value)) - PrePad - PostPad;
         EventId     = xTimer.Attribute("EPGEventID") == null ? "" : xTimer.Attribute("EPGEventID").Value;
         IsRecording = xTimer.Element("Recording").Value != "0";
         InError     = false;
     }
     catch (System.Exception ex)
     {
         logger.Error(ex, "Error parsing Timer XML");
         InError = true;
     }
 }
Beispiel #5
0
 public Programme(
     XElement xProg)
 {
     try
     {
         Id          = xProg.Element("eventid").Value;
         Title       = xProg.Element("titles").Element("title").Value;
         Description = xProg.Element("events")?.Element("event")?.Value ?? "";
         Channel     = AllChannels.FirstOrDefault(c => c.EpgId == xProg.Attribute("channel").Value);
         StartTime   = DateTime.ParseExact(
             xProg.Attribute("start").Value,
             new[] { "yyyyMMddHHmmss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
         StopTime = DateTime.ParseExact(
             xProg.Attribute("stop").Value,
             new[] { "yyyyMMddHHmmss" },
             CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
         InError = false;
     }
     catch (System.Exception ex)
     {
         logger.Error(ex, "Error parsing Programme XML");
         InError = true;
     }
 }
Beispiel #6
0
        public async Task <Channel> CreateChannel(string name, string description, DateTime createdAt, string ownerId, IEnumerable <Track> tracks)
        {
            Track[] trackArray = tracks.Distinct(TrackComparer.Default).ToArray();

            string  channelId  = Guid.NewGuid().ToString();
            Channel newChannel = new Channel
            {
                Id            = channelId,
                Name          = name,
                Discriminator = (ushort)AllChannels.Count(channel => channel.Name == name),
                Description   = description,
                CreatedAt     = createdAt,
                OwnerId       = ownerId,
                ChannelTracks = trackArray.Select((track, index) => new ChannelTrack
                {
                    ChannelId = channelId,
                    TrackId   = track.Id,
                    Order     = (uint)index
                }).ToList()
            };

            _appDbContext.Tracks.AddRange(trackArray.Except(_appDbContext.Tracks, TrackComparer.Default));
            _appDbContext.Channels.Add(newChannel);

            await _appDbContext.SaveChangesAsync();

            return(newChannel);
        }
Beispiel #7
0
        public override async void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            base.OnNavigatedTo(e, viewModelState);

            this.PropertyChanged += PropChanged;
            AllChannels           = await OperateAsyncOperation(_channelRepository.GetChannels(ChannelCategory.Hepsi));

            CurrentChannel = AllChannels.FirstOrDefault(a => a.Channel.Id == (JsonConvert.DeserializeObject <ChannelModelView>(e.Parameter.ToString())).Channel.Id);
        }
Beispiel #8
0
        public ChannelModel FindChannel(string id, string title = null)
        {
            var channel = AllChannels.FirstByIdOrNull(id);

            return(channel ?? new GeneralChannelModel(id, ChannelType.InviteOnly)
            {
                Title = title
            });
        }
Beispiel #9
0
        private static void OnLogout(LogoutEventArgs e)
        {
            if (e == null || !(e.Mobile is PlayerMobile))
            {
                return;
            }

            var user = (PlayerMobile)e.Mobile;

            AllChannels.Where(c => c.IsUser(user)).ForEach(c => c.Leave(user));
        }
Beispiel #10
0
        private static void OnLogin(LoginEventArgs e)
        {
            if (e == null || !(e.Mobile is PlayerMobile))
            {
                return;
            }

            var user = (PlayerMobile)e.Mobile;

            AllChannels.Where(c => user.AccessLevel <= c.Access && c.Available && c.AutoJoin).ForEach(c => c.Join(user));
        }
Beispiel #11
0
    /// <summary>
    /// Given a (shy internal) channel number, get the Channel
    /// </summary>
    /// <param name="internalChannelNumber"></param>
    /// <returns></returns>
    private Channel GetChannelByInternalNumber(
        int internalChannelNumber)
    {
        if (AllChannels.ContainsKey(internalChannelNumber))
        {
            return(AllChannels[internalChannelNumber]);
        }

        if (RadioChannels.ContainsKey(internalChannelNumber))
        {
            return(RadioChannels[internalChannelNumber]);
        }

        return(null);
    }
Beispiel #12
0
        private async void PropChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == nameof(CurrentChannel))
            {
                if (!CurrentChannel.Channel.IsSpecial) // Normal channel
                {
                    OperateMediaStreamResult(await AdaptiveMediaSource.CreateFromUriAsync(new Uri(CurrentChannel.Channel.URL, UriKind.RelativeOrAbsolute)));
                }
                else // Special channel, request for a valid stream url.
                {
                }
            }
            else if (e.PropertyName == nameof(CurrentSource) && CurrentSource != null)
            {
                AvailableBitrates = new ObservableCollection <BitrateModelView>();
                foreach (var bitrate in CurrentSource.AvailableBitrates.Where(a => a != 0))
                {
                    AvailableBitrates.Add(new BitrateModelView()
                    {
                        Bitrate = bitrate
                    });
                }

                OnPropertyChanged("AvailableBitrates");
                if (CurrentSettings.PreferedQuality == QualityEnumModel.Düşük)
                {
                    SelectedBitrate = AvailableBitrates.OrderBy(b => b.Bitrate).FirstOrDefault(a => a.Bitrate == CurrentSource.CurrentPlaybackBitrate);
                }
                else if (CurrentSettings.PreferedQuality == QualityEnumModel.Yüksek)
                {
                    SelectedBitrate = AvailableBitrates.OrderByDescending(b => b.Bitrate).FirstOrDefault(a => a.Bitrate == CurrentSource.CurrentPlaybackBitrate);
                }
                else if (CurrentSettings.PreferedQuality == QualityEnumModel.Orta)
                {
                    SelectedBitrate = AvailableBitrates.OrderBy(b => b.Bitrate).FirstOrDefault(a => a.Bitrate == AvailableBitrates[AvailableBitrates.Count / 2].Bitrate);
                }
            }
            else if (e.PropertyName == nameof(SelectedBitrate) && SelectedBitrate != null && CurrentSource != null && SelectedBitrate.Bitrate != CurrentSource.CurrentPlaybackBitrate)
            {
                CurrentSource.DesiredMinBitrate = SelectedBitrate.Bitrate;
            }
            else if (e.PropertyName == nameof(AllChannels))
            {
                GroupedChannels = AllChannels.OrderBy(b => b.Channel.Name).GroupBy(a => a.Channel.Category);
            }
        }
 public void CleanUp()
 {
     ConnectCallbackSent = false;
     ChannelsAndChannelGroupsAwaitingConnectCallback.Clear();
     channelEntitiesDictionary.Clear();
     AllPresenceChannelsOrChannelGroups.Clear();
     AllNonPresenceChannelsOrChannelGroups.Clear();
     AllChannels.Clear();
     AllChannelGroups.Clear();
     AllSubscribedChannelsAndChannelGroups.Clear();
     CompiledUserState = String.Empty;
     CurrentSubscribedChannelsCount      = 0;
     CurrentSubscribedChannelGroupsCount = 0;
     HasChannelGroups           = false;
     HasChannels                = false;
     HasChannelsOrChannelGroups = false;
     HasPresenceChannels        = false;
 }
Beispiel #14
0
        public async Task UpdateChannel(string oldName, Channel channel)
        {
            if (oldName != channel.Name)
            {
                Channel[] channelsWithNewName = AllChannels.Where(otherChannel => otherChannel.Name == channel.Name)
                                                .ToArray();

                if (channelsWithNewName.Length == 0)
                {
                    channel.Discriminator = 0;
                }
                else
                {
                    channel.Discriminator = (ushort)(channelsWithNewName.Max(otherChannel => otherChannel.Discriminator) + 1);
                }
            }

            _appDbContext.Channels.Update(channel);
            await _appDbContext.SaveChangesAsync();
        }
Beispiel #15
0
        private static void OnSpeech(SpeechEventArgs e)
        {
            if (e.Handled || e.Blocked || !(e.Mobile is PlayerMobile) || String.IsNullOrWhiteSpace(e.Speech) ||
                e.Speech.Length < 3 || e.Speech[0] != CMOptions.ChatPrefix)
            {
                return;
            }

            var pm   = (PlayerMobile)e.Mobile;
            var args = e.Speech.Substring(1).Split(' ');

            if (args.Length < 2)
            {
                return;
            }

            string token = args[0];

            var channel = AllChannels.FirstOrDefault(c => c.Available && c.Token == token && c.Access <= e.Mobile.AccessLevel);

            if (channel == null)
            {
                return;
            }

            e.Handled = true;
            e.Blocked = true;

            if (Insensitive.Equals(args[1], "join"))
            {
                if (channel.Join(pm))
                {
                }

                return;
            }

            if (Insensitive.Equals(args[1], "leave"))
            {
                if (channel.Leave(pm))
                {
                }

                return;
            }

            if (pm.AccessLevel > AccessLevel.Counselor)
            {
                if (Insensitive.Equals(args[1], "kick"))
                {
                    if (args.Length > 2)
                    {
                        PlayerMobile toKick = channel.Users.Keys.FirstOrDefault(u => Insensitive.Equals(u.RawName, args[2]));

                        if (toKick != null && pm.AccessLevel > toKick.AccessLevel && channel.Kick(toKick))
                        {
                        }
                    }

                    return;
                }

                if (Insensitive.Equals(args[1], "ban"))
                {
                    if (args.Length > 2)
                    {
                        PlayerMobile toBan = channel.Users.Keys.FirstOrDefault(u => Insensitive.Equals(u.RawName, args[2]));

                        TimeSpan duration = TimeSpan.Zero;

                        if (args.Length > 3)
                        {
                            double mins;

                            if (Double.TryParse(args[3], out mins))
                            {
                                duration = TimeSpan.FromMinutes(mins);
                            }
                        }

                        if (toBan != null && pm.AccessLevel > toBan.AccessLevel && channel.Ban(toBan, duration))
                        {
                        }
                    }

                    return;
                }
            }

            var tmp = args.ToList();

            tmp.RemoveAt(0);
            args = tmp.ToArray();
            tmp.Clear();

            if (channel.Message(pm, String.Join(" ", args)))
            {
            }
        }
Beispiel #16
0
        public async Task LoadAllChannels(bool forceDownload = false)
        {
            AllChannels.Clear();
            FavoriteChannels.Clear();

            StorageFile file = null;

            try { file = await ApplicationData.Current.LocalFolder.GetFileAsync("channels.json"); }
            catch { }

            string data = null;

            if (file == null || forceDownload)
            {
                data = await ChannelsHelper.DownloadJson(ChannelsHelper.CHANNELS_URL);

                if (data != null)
                {
                    file = await ApplicationData.Current.LocalFolder.CreateFileAsync("channels.json", CreationCollisionOption.ReplaceExisting);

                    var writer = new StreamWriter(await file.OpenStreamForWriteAsync());
                    await writer.WriteAsync(data);

                    writer.Dispose();
                }
            }
            else
            {
                var reader = new StreamReader(await file.OpenStreamForReadAsync());
                data = await reader.ReadToEndAsync();

                reader.Dispose();
            }

            if (data == null)
            {
                return;
            }

            var channels = JsonConvert.DeserializeObject(data) as JContainer;

            foreach (var asset in ChannelsHelper.ChannelsAssets)
            {
                var item = new ChannelItem();
                item.Key    = asset.Key;
                item.Image  = asset.Value[0];
                item.Color1 = asset.Value[1];
                item.Color2 = asset.Value[2];

                var channel = channels.FirstOrDefault((element) => element["key"].Value <string>() == asset.Key);

                if (channel != null)
                {
                    item.ID          = channel.Value <int>("id");
                    item.Name        = channel.Value <string>("name");
                    item.Description = channel.Value <string>("description");
                }

                LoadChannelStreams(item);
                LoadTrackHistory(item);

                AllChannels.Add(item);
            }

            if (AllChannels.Count > 2)
            {
                AllChannels[0].Next = AllChannels[1];
                AllChannels[AllChannels.Count - 1].Prev = AllChannels[AllChannels.Count - 2];
            }

            for (int i = 1; i < AllChannels.Count - 1; i++)
            {
                AllChannels[i].Prev = AllChannels[i - 1];
                AllChannels[i].Next = AllChannels[i + 1];
            }

            await LoadFavoriteChannels();
        }
        public void ResetChannelsAndChannelGroupsAndBuildState()
        {
            AllPresenceChannelsOrChannelGroups.Clear();
            AllNonPresenceChannelsOrChannelGroups.Clear();
            ChannelsAndChannelGroupsAwaitingConnectCallback.Clear();
            AllChannels.Clear();
            AllChannelGroups.Clear();
            AllSubscribedChannelsAndChannelGroups.Clear();
            HasChannelGroups                    = false;
            HasChannels                         = false;
            HasPresenceChannels                 = false;
            HasChannelsOrChannelGroups          = false;
            CurrentSubscribedChannelsCount      = 0;
            CurrentSubscribedChannelGroupsCount = 0;

            foreach (var ci in channelEntitiesDictionary)
            {
                if (ci.Value.IsSubscribed)
                {
                    if (ci.Key.IsChannelGroup)
                    {
                        CurrentSubscribedChannelGroupsCount++;
                        AllChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                    else
                    {
                        CurrentSubscribedChannelsCount++;
                        AllChannels.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                    AllSubscribedChannelsAndChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));

                    if (ci.Key.IsPresenceChannel)
                    {
                        AllPresenceChannelsOrChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                    else
                    {
                        AllNonPresenceChannelsOrChannelGroups.Add(new ChannelEntity(ci.Key, ci.Value));
                    }

                    if (ci.Value.IsAwaitingConnectCallback)
                    {
                        ChannelsAndChannelGroupsAwaitingConnectCallback.Add(new ChannelEntity(ci.Key, ci.Value));
                    }
                }
                #if (ENABLE_PUBNUB_LOGGING)
                this.PubNubInstance.PNLog.WriteToLog(string.Format("ResetChannelsAndChannelGroupsAndBuildState: channelEntities subscription key/val {0} {1}", ci.Key.ChannelOrChannelGroupName, ci.Value.IsSubscribed), PNLoggingMethod.LevelInfo);
                #endif
            }
            if (CurrentSubscribedChannelGroupsCount > 0)
            {
                HasChannelGroups = true;
            }
            if (CurrentSubscribedChannelsCount > 0)
            {
                HasChannels = true;
            }
            if (AllPresenceChannelsOrChannelGroups.Count > 0)
            {
                HasPresenceChannels = true;
            }
            if (HasChannels || HasChannelGroups)
            {
                HasChannelsOrChannelGroups = true;
            }
            #if (ENABLE_PUBNUB_LOGGING)
            this.PubNubInstance.PNLog.WriteToLog(string.Format("PrevCompiledUserState: {0}", CompiledUserState), PNLoggingMethod.LevelInfo);
            #endif

            CompiledUserState = Helpers.BuildJsonUserState(AllSubscribedChannelsAndChannelGroups);

            #if (ENABLE_PUBNUB_LOGGING)
            this.PubNubInstance.PNLog.WriteToLog(string.Format("CompiledUserState: {0}", CompiledUserState), PNLoggingMethod.LevelInfo);
            #endif
        }
Beispiel #18
0
 public LogisticChannel(string name)
 {
     this.name = name;
     AllChannels.Add(this);
 }
 public void AddChannel(Channel channel)
 {
     AllChannels.Add(channel);
 }