Esempio n. 1
0
        protected override void UpdateGuiProperties()
        {
            base.UpdateGuiProperties();

            ChannelName     = CurrentChannel != null ? CurrentChannel.Name : string.Empty;
            ChannelLogoType = CurrentChannel.GetFanArtMediaType();
            _channel        = CurrentChannel;
        }
        public void ApplyOSAMeasureAll( )
        {
            try {
                DateTime startMeas = DateTime.UtcNow;
                SetAlignMode(true);

                Spectrum_OSA.PerformSingleSweep( );

                if (EnableAllChMeasurement) // All channel's ON
                {
                    // just measure secleted channel
                    SpectrumMeasure sm = (SpectrumMeasure)htChannelMeasure["Ch" + CurrentChannel.ToString()];
                    if (sm != null)
                    {
                        Spectrum_OSA.StartWavelength  = sm.StartWavelength;
                        Spectrum_OSA.StopWavelength   = sm.StopWavelength;
                        Spectrum_OSA.CenterWavelength = sm.CenterWavelength;
                        Spectrum_OSA.SpanWavelength   = 5.2f;
                        Spectrum_OSA.PerformSingleSweep();
                        Thread.Sleep(2000);
                        GetMeasureResult("Ch" + CurrentChannel.ToString());
                        Thread.Sleep(1000);
                    }
                    // don't measure 4 of them.
                    //for (int i = 0; i < 4; i++)
                    //{
                    //    SpectrumMeasure sm = (SpectrumMeasure)htChannelMeasure["Ch" + i.ToString()];
                    //    if (sm != null)
                    //    {
                    //        Spectrum_OSA.StartWavelength = sm.StartWavelength;
                    //        Spectrum_OSA.StopWavelength = sm.StopWavelength;
                    //        Spectrum_OSA.CenterWavelength = sm.CenterWavelength;
                    //        Spectrum_OSA.SpanWavelength = 5.2f;
                    //        Spectrum_OSA.PerformSingleSweep();
                    //        Thread.Sleep(2000);
                    //        GetMeasureResult("Ch" + i.ToString());
                    //        Thread.Sleep(1000);
                    //    }

                    //}
                }
                else // just one channel ON.
                {
                    GetMeasureResult(true);

                    SetAlignMode(false);
                    Spectrum_OSA.PerformSingleSweep();

                    GetMeasureResult(false);
                }
                FireOSAResultDataChanged( );
            }
            catch (Exception ex) {
                throw new Exception("MeasureAll ex=" + ex.ToString( ));
            }
            finally {
            }
        }
        protected override void UpdateGuiProperties()
        {
            base.UpdateGuiProperties();

            ChannelName     = CurrentChannel?.Name ?? string.Empty;
            ChannelLogoType = CurrentChannel.GetFanArtMediaType();
            ChannelNumber   = CurrentChannel?.ChannelNumber ?? 0;
            _channel        = CurrentChannel;
        }
Esempio n. 4
0
        public static async Task SetVoiceChannel(IVoiceChannel channel)
        {
            if (channel == null)
            {
                await CurrentChannel.DisconnectAsync();
            }

            CurrentChannel = channel;
            await CurrentChannel?.ConnectAsync(false, true);
        }
        public void ShutdownRevival()
        {
            CurrentStream.Load(savedSamplesPlayed);
            savedSamplesPlayed = 0;

            if (CurrentChannel != null)
            {
                CurrentChannel.ReapplySettings();
            }
        }
        /// <summary>
        /// string representation of the RSS feed.
        /// </summary>
        /// <returns>An rss formatted string</returns>
        public override string ToString()
        {
            StringBuilder DocumentString = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<rss xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\" xmlns:media=\"http://search.yahoo.com/mrss/\" version=\"2.0\">\r\n");

            foreach (Channel CurrentChannel in Channels)
            {
                DocumentString.Append(CurrentChannel.ToString());
            }
            DocumentString.Append("</rss>");
            return(DocumentString.ToString());
        }
Esempio n. 7
0
        private void AcquirePushChannel()
        {
            string notification_hub_name = "Set Your Notification Name Here";

            CurrentChannel = HttpNotificationChannel.Find(notification_hub_name);
            if (CurrentChannel == null)
            {
                CurrentChannel = new HttpNotificationChannel(notification_hub_name);
                CurrentChannel.Open();
                CurrentChannel.BindToShellToast();
            }
            CurrentChannel.ChannelUriUpdated +=
                new EventHandler <NotificationChannelUriEventArgs>(async(o, args) =>
            {
                // Register for notifications using the new channel
                System.Exception exception = null;
                try
                {
                    var push = new Push(MobileService);
                    await push.RegisterNativeAsync(CurrentChannel.ChannelUri.ToString());
                }
                catch (System.Exception ex)
                {
                    CurrentChannel.Close();
                    exception = ex;
                }
                if (exception != null)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        MessageBox.Show(exception.Message,
                                        "Registering for Push Notifications",
                                        MessageBoxButton.OK);
                    });
                }
            });
            CurrentChannel.ShellToastNotificationReceived +=
                new EventHandler <NotificationEventArgs>((o, args) =>
            {
                string message = "";
                foreach (string key in args.Collection.Keys)
                {
                    message += key + " : " + args.Collection[key] + ", ";
                }
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(message);
                });
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Handles channel user state changes.
        /// </summary>
        private async Task UserStateHandler(ulong userId, bool talking)
        {
            UserVoiceState state = new UserVoiceState
            {
                User    = CurrentChannel.GetUser(userId),
                Talking = talking
            };

            if (UserStateChange != null)
            {
                await UserStateChange(this, new UserEventArgs(state));
            }

            await Task.CompletedTask;
        }
Esempio n. 9
0
        /// <summary>
        /// 获取当前状态,用于向线程池加入任务时传递参数
        /// </summary>
        /// <returns></returns>
        private PlayerState GetPlayerState()
        {
            PlayerState ps = null;

            if (CheckAccess())
            {
                ps = new PlayerState(Settings.User == null ? null : (User)Settings.User.Clone(),
                                     CurrentChannel == null ? null : (Channel)CurrentChannel.Clone(),
                                     CurrentSong == null ? null : (Song)CurrentSong.Clone());
            }
            else
            {
                Dispatcher.Invoke(new Action(() => { ps = GetPlayerState(); }));
            }
            return(ps);
        }
Esempio n. 10
0
        /// <summary>
        /// Start this module.
        /// </summary>
        public async Task StartAsync()
        {
            if (_server.DiscordHandler.CurrentUser.VoiceChannel != null)
            {
                CurrentChannel = _server.DiscordHandler.CurrentUser.VoiceChannel;
                Client         = await CurrentChannel.ConnectAsync();

                OutStream = Client.CreateDirectPCMStream(AudioApplication.Music, AudioHelpers.BITRATE);

                await LeaveVoice();
            }

            new Task(async() => await StartAsyncSend()).Start();
            new Task(async() => await StartAsyncReceive()).Start();

            await Task.CompletedTask;
        }
Esempio n. 11
0
 public MainWindow()
 {
     InitializeComponent();
     radio.Read(); //Deserialize
     CurrentChannel.Add(new ChannelModel()
     {
         Brush = Brushes.Gray, ChannelName = "Channel 1"
     });
     CurrentChannel.Add(new ChannelModel()
     {
         Brush = Brushes.CornflowerBlue, ChannelName = "Channel 2"
     });
     CurrentChannel.Add(new ChannelModel()
     {
         Brush = Brushes.CadetBlue, ChannelName = "Channel 3"
     });
     CurrentChannel.Add(new ChannelModel()
     {
         Brush = Brushes.LightBlue, ChannelName = "Channel 4"
     });
 }
        public void StopSourceVoice(StopReason stopReason)
        {
            JMOD.Sound.DebugOutput("{0} - StopSourceVoice called in SourceVoiceSlot {1}", DateTime.Now.TimeOfDay, ID);
            if (CurrentSourceVoice != null && !CurrentSourceVoice.Done)
            {
                var result = CurrentSourceVoice.Stop();
                if (result.IsFailure)       // to be removed later
                {
                    throw new Exception(result.Code + " - " + result.Description);
                }
            }

            if (stopReason == StopReason.Ended)
            {
                CurrentChannel.HandleFinishedSlot(true);
            }
            else if (stopReason == StopReason.Stopped)
            {
                CurrentChannel.HandleFinishedSlot(false);
            }
            else if (stopReason == StopReason.Stolen)
            {
                CurrentChannel.HandleStolenSlot();
            }

            if (CurrentSourceVoice != null)
            {
                JMOD.Sound.DebugOutput("Flushing buffers");
                var result = CurrentSourceVoice.FlushSourceBuffers();
                if (result.IsFailure)       // to be removed later
                {
                    throw new Exception(result.Code + " - " + result.Description);
                }
            }
            system.ReleaseSourceVoiceSlot(this);
            CurrentChannel     = null;
            CurrentSourceVoice = null;
        }
        public void StopSourceVoice(StopReason stopReason)
        {
            JMOD.Sound.DebugOutput("{0} - StopSourceVoice called in Stream SourceVoiceSlot", DateTime.Now.TimeOfDay);
            if (CurrentSourceVoice != null)
            {
                Result result;
                if (!CurrentSourceVoice.Done)
                {
                    result = CurrentSourceVoice.Stop();
                    if (result.IsFailure)       // to be removed later
                    {
                        throw new Exception(result.Code + " - " + result.Description);
                    }
                }
                result = CurrentSourceVoice.FlushSourceBuffers();
                if (result.IsFailure)
                {
                    throw new Exception(result.Code + " - " + result.Description);
                }
            }

            if (stopReason == StopReason.Ended)
            {
                CurrentChannel.HandleFinishedSlot(true);
            }
            else if (stopReason == StopReason.Stopped)
            {
                CurrentChannel.HandleFinishedSlot(false);
            }
            else
            {
                throw new NotImplementedException();
            }

            CurrentChannel = null;
        }
        public void ShutdownRevival()
        {
            if (savedSourceVoiceState == null)      // nothing to resume here
            {
                return;
            }

            if (savedSourceVoiceState.Done)
            {
                CurrentSourceVoice = null;
                StopSourceVoice(StopReason.Ended);      // WARNING: This may not work as intended (glanced over, but not tested)
                return;
            }

            var format = CurrentChannel.Sound.Format;
            NormalSourceVoice sourceVoice = new NormalSourceVoice(system, format);

            CurrentSourceVoice = sourceVoices[format] = sourceVoice;
            sourceVoice.SetupBuffer(CurrentChannel.Sound, CurrentChannel.Looping, (int)savedSourceVoiceState.SamplesPlayed);

            CurrentChannel.ReapplySettings();

            savedSourceVoiceState = null;
        }
Esempio n. 15
0
        /// <summary>
        /// Tune to channel
        /// </summary>
        /// <param name="subChannelId"></param>
        /// <param name="channel"></param>
        /// <returns></returns>
        private ITvSubChannel DoTune(int subChannelId, IChannel channel, bool ignorePMT)
        {
            Log.Log.WriteFile("dvbip:  Tune:{0}", channel);
            ITvSubChannel ch = null;

            try
            {
                DVBIPChannel dvbipChannel = channel as DVBIPChannel;
                if (dvbipChannel == null)
                {
                    Log.Log.WriteFile("Channel is not a IP TV channel!!! {0}", channel.GetType().ToString());
                    return(null);
                }

                Log.Log.Info("dvbip: tune: Assigning oldChannel");
                DVBIPChannel oldChannel = CurrentChannel as DVBIPChannel;
                if (CurrentChannel != null)
                {
                    //@FIX this fails for back-2-back recordings
                    //if (oldChannel.Equals(channel)) return _mapSubChannels[0];
                    Log.Log.Info("dvbip: tune: Current Channel != null {0}", CurrentChannel.ToString());
                }
                else
                {
                    Log.Log.Info("dvbip: tune: Current channel is null");
                }
                if (_graphState == GraphState.Idle)
                {
                    Log.Log.Info("dvbip: tune: Building graph");
                    BuildGraph();
                    if (_mapSubChannels.ContainsKey(subChannelId) == false)
                    {
                        subChannelId = GetNewSubChannel(channel);
                    }
                }
                else
                {
                    Log.Log.Info("dvbip: tune: Graph is running");
                }

                //_pmtPid = -1;

                Log.Log.Info("dvb:Submiting tunerequest Channel:{0} subChannel:{1} ", channel.Name, subChannelId);
                if (_mapSubChannels.ContainsKey(subChannelId) == false)
                {
                    Log.Log.Info("dvb:Getting new subchannel");
                    subChannelId = GetNewSubChannel(channel);
                }
                else
                {
                }
                Log.Log.Info("dvb:Submit tunerequest size:{0} new:{1}", _mapSubChannels.Count, subChannelId);
                _mapSubChannels[subChannelId].CurrentChannel = channel;

                _mapSubChannels[subChannelId].OnBeforeTune();

                if (_interfaceEpgGrabber != null)
                {
                    _interfaceEpgGrabber.Reset();
                }

                Log.Log.WriteFile("dvb:Submit tunerequest calling put_TuneRequest");
                _lastSignalUpdate = DateTime.MinValue;

                _mapSubChannels[subChannelId].OnAfterTune();
                ch = _mapSubChannels[subChannelId];
                Log.Log.Info("dvbip: tune: Running graph for channel {0}", ch.ToString());
                Log.Log.Info("dvbip: tune: SubChannel {0}", ch.SubChannelId);

                try
                {
                    RunGraph(ch.SubChannelId, dvbipChannel.Url);
                }
                catch (TvExceptionNoPMT)
                {
                    if (!ignorePMT)
                    {
                        throw;
                    }
                }

                Log.Log.Info("dvbip: tune: Graph running. Returning {0}", ch.ToString());
                return(ch);
            }
            catch (Exception ex)
            {
                if (ch != null)
                {
                    FreeSubChannel(ch.SubChannelId);
                }
                Log.Log.Write(ex);
                throw;
            }
            //unreachable return null;
        }
Esempio n. 16
0
 private static void Client_OnDisconnected(object sender, TwitchLib.Communication.Events.OnDisconnectedEventArgs e)
 {
     BotTools.LogLine("RazBot lost connection to Twitch, reconnecting...");
     Client = NewTwitchConnection();
     Client.JoinChannel(CurrentChannel.ToLower());
 }
Esempio n. 17
0
 public static void LeaveChannel()
 {
     Client.LeaveChannel(CurrentChannel.ToLower());
 }
Esempio n. 18
0
 public char GetColorCharacter() =>
 IsModerator ? ModeratorColorCharacter :
 CurrentChannel?.IsVoiced(this) == true ? VoicedColorCharacter : NormalColorCharacter;
Esempio n. 19
0
        public override void OnPacket(InPacket iPacket)
        {
            try
            {
                iPacket.Decrypt(CRYPT_KEY);

                GameOpcodes uOpcode    = (GameOpcodes)iPacket.ReadUShort();
                int         uSize      = iPacket.ReadInt();
                bool        isCompress = iPacket.ReadBool();
                int         cSize      = 0;
                if (isCompress == true)
                {
                    cSize = iPacket.ReadInt();
                    LogFactory.GetLog("Main").LogWarning("[{0}] pacote comprimido chegada {1} ({2})", Login, (int)uOpcode, uOpcode.ToString());
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("[{0}] de chegada de pacotes {1} ({2})", Login, (int)uOpcode, uOpcode.ToString());
                }

                LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());

                switch (uOpcode)
                {
                case GameOpcodes.EVENT_HEART_BIT_NOT:     // 0
                    OnHeartBeatNot();
                    break;

                case GameOpcodes.EVENT_CHANGE_CHARACTER_INFO_REQ:     //1618
                    InfoChars.ChangeCharInfo(this);
                    break;

                case GameOpcodes.EVENT_VERIFY_ACCOUNT_REQ:     // 2
                    MyUser.OnLogin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_CURRENT_CHARACTER_REQ:
                    MyCommon.SetCurretChar(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_FULL_SP_INFO_REQ:     // 423 0x1A7
                    MyCommon.OnGetFullSPInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_PET_COSTUM_LIST_REQ:     // 517 0x205
                    MyCommon.OnPetCostumList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_INVEN_BUFF_ITEM_LIST_REQ:     // 1226 0x04CA
                    MyCommon.OnInvenBuffItemList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DEPOT_INFO_REQ:     // 1340 0x053C
                    MyCommon.OnDepotInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAT_CLIENT_INFO:     // 226 0x00E2
                    MyCommon.OnStatClientInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_COST_RATE_FOR_GAMBLE_BUY_REQ:     // 871 0x0367
                    MyCommon.OnCostRateForGambleBuy(this);
                    break;

                case GameOpcodes.EVENT_REGISTER_NICKNAME_REQ:     // 134 0x0086
                    MyUser.OnRegisterNick(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_IDLE_STATE_REQ:     // 835 0x0343
                    MyCommon.OnSetIDLE(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAR_SELECT_JOIN_REQ:     // 1557 0x0613
                    MyUser.OnCharSelectJoin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHOICE_BOX_LIST_REQ:     // 1012 0x03F4
                    MyCommon.OnChoiceBoxList(this);
                    break;

                case GameOpcodes.EVENT_EXP_POTION_LIST_REQ:     // 1338 0x053A
                    MyCommon.OnExpPotionList(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_CATALOG_REQ:     // 1114 0x054A
                    MyCommon.OnAgitStoreCatalog(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_MATERIAL_REQ:     // 1116 0x045C
                    MyCommon.OnAgitStoreMaterial(this);
                    break;

                case GameOpcodes.EVENT_AGIT_MAP_CATALOGUE_REQ:     // 1106 0x0452
                    MyCommon.OnAgitMapCatalogue(this);
                    break;

                case GameOpcodes.EVENT_FAIRY_TREE_LV_TABLE_REQ:     // 1184 0x04A0
                    MyCommon.OnFaityTreeLvTable(this);
                    break;

                case GameOpcodes.EVENT_INVITE_DENY_NOT:     // 348 0x015C
                    InviteDeny = iPacket.ReadBool();
                    break;

                case GameOpcodes.EVENT_GET_USER_DONATION_INFO_REQ:     // 523 0x020B
                    MyCommon.OnGetUserDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_RECOMMEND_FULL_INFO_REQ:     // 567 0x0237
                    MyCommon.OnRecommentUser(this);
                    break;

                case GameOpcodes.EVENT_USER_BINGO_DATA_REQ:     // 654 0x28E
                    MyCommon.OnUserBingoData(this);
                    break;

                case GameOpcodes.EVENT_CHANNEL_LIST_REQ:     // 14 0x0E
                    MyCommon.OnChannelList(this);
                    break;

                case GameOpcodes.EVENT_DONATION_INFO_REQ:     // 525 0x020D
                    MyCommon.OnDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_ENTER_CHANNEL_REQ:     // 12 0x0C
                    MyUser.OnEnterChannel(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_CHANNEL_NOT:     // 26
                    MyUser.OnLeaveChannel(this);
                    break;

                case GameOpcodes.EVENT_CREATE_ROOM_REQ:
                    MyUser.OnCreateRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOM_INFO_REQ:
                    CurrentRoom.OnChangeRoomInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOMUSER_INFO_REQ:
                    CurrentRoom.OnChangeUserInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_ROOM_REQ:
                    CurrentRoom.OnLeaveRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_LIST_REQ:
                    CurrentChannel.OnRoomList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_JOIN_ROOM_REQ:
                    CurrentChannel.OnJoinRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_START_GAME_REQ:
                    CurrentRoom.StartGame(this, iPacket);
                    break;

                case GameOpcodes.EVENT_RELAY_LOADING_STATE:
                    CurrentRoom.OnLoadState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LOAD_COMPLETE_NOT:
                    //MyUser.LoadComplete(this, iPacket);
                    CurrentRoom.OnLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAGE_LOAD_COMPLETE_NOT:
                    //MyUser.StageLoadComplete(this, iPacket);
                    CurrentRoom.OnStageLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_MEMBER_PING_INFO_REQ:
                    CurrentRoom.OnPingInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_ROOMUSER_IDLE_STATE_REQ:
                    CurrentRoom.OnIdleInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_END_GAME_REQ:
                    CurrentRoom.OnGameEnd(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAT_REQ:
                    CurrentChannel.OnChat(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_GAME_REQ:
                    CurrentRoom.OnLeaveGame(this, iPacket);
                    break;

                case GameOpcodes.EVENT_EQUIP_ITEM_REQ:
                    MyCharacter.OnEquipItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_LOOK_EQUIP_REQ:
                    MyCharacter.OnChangeEquipInRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_PRESS_STATE_REQ:
                    CurrentRoom.OnSetPressState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SKILL_TRAINING_REQ:
                    MyCharacter.OnTrainSkill(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_SKILL_REQ:
                    MyCharacter.OnSetSkill(this, iPacket);
                    break;

                case GameOpcodes.DB_EVENT_SYSTEM_GUIDE_COMPLETE_INFO_REQ:
                    MyCommon.SendGuideCompleteInfo(this);
                    break;

                case GameOpcodes.EVENT_CASHBACK_EXTRA_RATIO_INFO_REQ:
                    MyShop.CashRatio(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_REQ:
                    MyShop.packageInfo(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_DETAIL_REQ:
                    MyShop.packageInfoDetail(this, iPacket);
                    break;

                default:
                {
                    LogFactory.GetLog("Main").LogWarning("pacote indefinido foi recebido. Opcode: {0}({1})", (int)uOpcode, uOpcode.ToString());
                    LogFactory.GetLog("Main").LogHex("Pacote", iPacket.ToArray());
                    break;
                }
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogFatal(e);
                Close();
            }
        }
Esempio n. 20
0
        private async Task initializeInternal()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            // モデルの初期化
            try
            {
                await model.Initialize();

                await BasicSettingControlViewModel.Initialize();

                //await ChatPostControlViewModel.Initialize();
            }
            catch (Exception e)
            {
                AlertRequest.Raise(new Notification {
                    Title = "TVTCommentエラー", Content = $"初期化で予期しないエラーが発生しました\n{e.ToString()}"
                });
                CloseApplication();
                return;
            }
            if (model.State != Model.TVTCommentState.Working)
            {
                AlertRequest.Raise(new Notification {
                    Title = "TVTCommentエラー", Content = "Viewer側(TVTestプラグイン側)と接続できませんでした"
                });
                CloseApplication();
                return;
            }

            // 表示関係の設定復元
            Model.Serialization.WindowPositionEntity rect = model.Settings.View.MainWindowPosition;
            this.WindowPosition.X      = rect.X;
            this.WindowPosition.Y      = rect.Y;
            this.WindowPosition.Width  = rect.Width;
            this.WindowPosition.Height = rect.Height;

            ChatListColumnInfos = model.Settings.View.ChatListViewColumns?.Select(
                x => new Views.AttachedProperties.GridViewColumnSettingsBinder.ColumnInfo(x.Id, x.Width)
                ).ToArray();

            this.SelectedTab.Value = model.Settings.View.MainWindowTab;

            // ウィンドウの位置を復元したら最小化を解除
            Window window = Application.Current.MainWindow;

            window.WindowState = WindowState.Normal;

            // モデルのイベントハンドラを登録
            model.ChatCollectServiceModule.ErrorOccurredInChatCollecting  += model_ErrorOccurredInChatCollecting;
            model.ChatCollectServiceModule.ErrorOccurredInChatPosting     += model_ErrorOccurredInChatPosting;
            model.ChatCollectServiceModule.ErrorOccurredInServiceCreation += model_ErrorOccurredAtChatCollectServiceCreation;

            // モデルのプロパティを結びつける
            CurrentPlayTime = model.ChannelInformationModule.CurrentTime;
            CurrentChannel  = model.ChannelInformationModule.CurrentChannel;
            CurrentEvent    = model.ChannelInformationModule.CurrentEvent;

            disposables.Add(CurrentPlayTime.Subscribe(_ => updateWindowTitle()));
            disposables.Add(CurrentChannel.Subscribe(_ => updateWindowTitle()));
            disposables.Add(CurrentEvent.Subscribe(_ => updateWindowTitle()));

            // 旧ニコニコ実況が廃止されたので現状常にnull
            // 今後対応するときのためにとって置いてる
            forceValueData = new ReadOnlyObservableValue <Model.IForceValueData>(Observable.Return <Model.IForceValueData>(null));

            UseDefaultChatCollectService = model.DefaultChatCollectServiceModule.IsEnabled;

            model.CommandModule.ShowWindowCommandInvoked += commandModule_ShowWindowCommandInvoked;

            // コマンド生成
            ChangeChannelCommand = new DelegateCommand <Model.ChannelInfo>(channel => { if (channel != null)
                                                                                        {
                                                                                            model.ChannelInformationModule.SetCurrentChannel(channel);
                                                                                        }
                                                                           });

            AddChatCollectServiceCommand = new DelegateCommand <ShellContents.ChatCollectServiceAddListItemViewModel>(
                async x => { if (x != null)
                             {
                                 await addChatCollectService(x);
                             }
                },
                _ => !UseDefaultChatCollectService.Value
                );
            RemoveChatCollectServiceCommand = new DelegateCommand <Model.ChatCollectService.IChatCollectService>(
                service => { if (service != null)
                             {
                                 model.ChatCollectServiceModule.RemoveService(service);
                             }
                },
                _ => !UseDefaultChatCollectService.Value
                );
            UseDefaultChatCollectService.Subscribe(x => {
                AddChatCollectServiceCommand.RaiseCanExecuteChanged();
                RemoveChatCollectServiceCommand.RaiseCanExecuteChanged();
            });

            ClearChatsCommand = new DelegateCommand(() => model.ChatModule.ClearChats());
            AddWordNgCommand  = new DelegateCommand <Model.Chat>(chat =>
            {
                if (chat == null)
                {
                    return;
                }
                model.ChatModule.AddChatModRule(new Model.ChatModRules.WordNgChatModRule(model.ChatServices.SelectMany(x => x.ChatCollectServiceEntries), chat.Text));
            });
            AddUserNgCommand = new DelegateCommand <Model.Chat>(chat =>
            {
                if (chat == null)
                {
                    return;
                }
                model.ChatModule.AddChatModRule(new Model.ChatModRules.UserNgChatModRule(chat.SourceService.Owner.ChatCollectServiceEntries, chat.UserId));
            });
            CopyCommentCommand = new DelegateCommand <Model.Chat>(chat =>
            {
                if (chat == null)
                {
                    return;
                }
                Clipboard.SetText(chat.Text);
            });
            CopyUserCommand = new DelegateCommand <Model.Chat>(chat =>
            {
                if (chat == null)
                {
                    return;
                }
                Clipboard.SetText(chat.UserId);
            });

            OnPropertyChanged(null);
        }
Esempio n. 21
0
        public override void OnPacket(InPacket iPacket)
        {
            try
            {
                iPacket.Decrypt(CRYPT_KEY);

                GameOpcodes uOpcode    = (GameOpcodes)iPacket.ReadUShort();
                int         uSize      = iPacket.ReadInt();
                bool        isCompress = iPacket.ReadBool();
                int         cSize      = 0;
                if (isCompress == true)
                {
                    cSize = iPacket.ReadInt();
                    LogFactory.GetLog("Main").LogWarning("[{0}] Pacote comprimido {1}({2})", Login, (int)uOpcode, uOpcode.ToString());
                }
                else
                {
                    LogFactory.GetLog("Main").LogInfo("[{0}] Packet {1}({2})", Login, (int)uOpcode, uOpcode.ToString());
                }

                LogFactory.GetLog("Main").LogHex("Pacote: ", iPacket.ToArray());

                switch (uOpcode)
                {
                case GameOpcodes.HEART_BIT_NOT:     // 0
                    OnHeartBeatNot();
                    break;

                case GameOpcodes.EVENT_VERIFY_ACCOUNT_REQ:     // 2
                    MyUser.OnLogin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_FULL_SP_INFO_REQ:     // 423 0x1A7
                    MyCommon.OnGetFullSPInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_PET_COSTUM_LIST_REQ:     // 517 0x205
                    MyCommon.OnPetCostumList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_INVEN_BUFF_ITEM_LIST_REQ:     // 1226 0x04CA
                    MyCommon.OnInvenBuffItemList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DEPOT_INFO_REQ:     // 1340 0x053C
                    MyCommon.OnDepotInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAT_CLIENT_INFO:     // 226 0x00E2
                    MyCommon.OnStatClientInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_COST_RATE_FOR_GAMBLE_BUY_REQ:     // 871 0x0367
                    MyCommon.OnCostRateForGambleBuy(this);
                    break;

                case GameOpcodes.EVENT_ENTER_AGIT_REQ:    //AGITT
                    MyAgit.EnterAgit(this);
                    break;

                case GameOpcodes.EVENT_AGIT_LOADING_COMPLETE_REQ:    //AGITT
                    MyAgit.AgitLoadComplete(this);
                    break;

                case GameOpcodes.EVENT_REGISTER_NICKNAME_REQ:     // 134 0x0086
                    MyUser.OnRegisterNick(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_IDLE_STATE_REQ:     // 835 0x0343
                    MyCommon.OnSetIDLE(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAR_SELECT_JOIN_REQ:     // 1555 0x0613
                    MyUser.OnCharSelectJoin(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHOICE_BOX_LIST_REQ:     // 1012 0x03F4
                    MyCommon.OnChoiceBoxList(this);
                    break;

                case GameOpcodes.EVENT_EXP_POTION_LIST_REQ:     // 1338 0x053A
                    MyCommon.OnExpPotionList(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_CATALOG_REQ:     // 1114 0x054A
                    MyCommon.OnAgitStoreCatalog(this);
                    break;

                case GameOpcodes.EVENT_AGIT_STORE_MATERIAL_REQ:     // 1116 0x045C
                    MyCommon.OnAgitStoreMaterial(this);
                    break;

                case GameOpcodes.EVENT_AGIT_MAP_CATALOGUE_REQ:     // 1106 0x0452
                    MyCommon.OnAgitMapCatalogue(this);
                    break;

                case GameOpcodes.EVENT_FAIRY_TREE_LV_TABLE_REQ:     // 1184 0x04A0
                    MyCommon.OnFaityTreeLvTable(this);
                    break;

                case GameOpcodes.EVENT_INVITE_DENY_NOT:     // 348 0x015C
                    InviteDeny = iPacket.ReadBool();
                    break;

                case GameOpcodes.EVENT_GET_USER_DONATION_INFO_REQ:     // 523 0x020B
                    MyCommon.OnGetUserDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_RECOMMEND_FULL_INFO_REQ:     // 567 0x0237
                    MyCommon.OnRecommentUser(this);
                    break;

                case GameOpcodes.EVENT_USER_BINGO_DATA_REQ:     // 654 0x28E
                    MyCommon.OnUserBingoData(this);
                    break;

                case GameOpcodes.EVENT_CHANNEL_LIST_REQ:     // 14 0x0E
                    MyCommon.OnChannelList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DONATION_INFO_REQ:     // 525 0x020D
                    MyCommon.OnDonationInfo(this);
                    break;

                case GameOpcodes.EVENT_ENTER_CHANNEL_REQ:     // 12 0x0C
                    MyUser.OnEnterChannel(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_CHANNEL_NOT:     // 26
                    MyUser.OnLeaveChannel(this);
                    break;

                case GameOpcodes.EVENT_CREATE_ROOM_REQ:     // 24 방 만들기
                    MyUser.OnCreateRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOM_INFO_REQ:     // 28 0x1C 방의 게임모드 정보 바뀜
                    CurrentRoom.OnChangeRoomInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_ROOMUSER_INFO_REQ:     // 40 0x28 방의 유저 정보 바뀜
                    CurrentRoom.OnChangeUserInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_ROOM_REQ:     // 33 0x21 방에서 나가기 요청
                    CurrentRoom.OnLeaveRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_LIST_REQ:     // 16 0x10 방 목록 요청
                    CurrentChannel.OnRoomList(this, iPacket);
                    break;

                case GameOpcodes.EVENT_JOIN_ROOM_REQ:     // 20 방 입장 요청
                    CurrentChannel.OnJoinRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_START_GAME_REQ:     // 36 게임 시작 요청
                    CurrentRoom.OnGameStart(this, iPacket);
                    break;

                case GameOpcodes.EVENT_RELAY_LOADING_STATE:     // 842 게임로딩중 로딩진행도
                    CurrentRoom.OnLoadState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LOAD_COMPLETE_NOT:     // 39 로딩 끝났다는거 전송 (게임으로 들여보내짐)
                    CurrentRoom.OnLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_STAGE_LOAD_COMPLETE_NOT:     // 927 스테이지 로딩이 끝났다
                    CurrentRoom.OnStageLoadComplete(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ROOM_MEMBER_PING_INFO_REQ:     // 837 게임 멤버 핑 정보 요청 (게임시작 할때 쓰나봄)
                    CurrentRoom.OnPingInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GET_ROOMUSER_IDLE_STATE_REQ:     // 833 자리비움 상태 요청
                    CurrentRoom.OnIdleInfo(this, iPacket);
                    break;

                case GameOpcodes.EVENT_END_GAME_REQ:     // 게임 종료
                    CurrentRoom.OnGameEnd(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHAT_REQ:     // 6 채팅!
                    CurrentChannel.OnChat(this, iPacket);
                    break;

                case GameOpcodes.EVENT_LEAVE_GAME_REQ:     // 44 게임중 나가기
                    CurrentRoom.OnLeaveGame(this, iPacket);
                    break;

                case GameOpcodes.EVENT_EQUIP_ITEM_REQ:     // 62 장비 변경 요청
                    MyCharacter.OnEquipItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHANGE_LOOK_EQUIP_REQ:     // 860 방에서 장비변경 요청 (이게 선처리 된 후 EVENT_EQUIP_ITEM_REQ)
                    MyCharacter.OnChangeEquipInRoom(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_PRESS_STATE_REQ:     // 방에서 다른 용무중
                    CurrentRoom.OnSetPressState(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SKILL_TRAINING_REQ:     // 스킬 배우기
                    MyCharacter.OnTrainSkill(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SET_SKILL_REQ:     // 스킬 장착 요청
                    MyCharacter.OnSetSkill(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SERVER_LIST_REQ:
                    MyUser.SendServerList(this);
                    break;

                case GameOpcodes.EVENT_SQUARE_LIST_REQ:
                    square.SquareList(this);
                    break;

                case GameOpcodes.EVENT_ENTER_SQUARE_REQ:
                    square.enterSquare(this);
                    break;

                case GameOpcodes.EVENT_LEAVE_SQUARE_REQ:
                    square.LeaveSquare(this);
                    break;

                case GameOpcodes.EVENT_CASHBACK_EXTRA_RATIO_INFO_REQ:
                    MyShop.CashRatio(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_REQ:
                    MyShop.packageInfo(this);
                    break;

                case GameOpcodes.EVENT_PACKAGE_INFO_DETAIL_REQ:
                    MyShop.packageInfoDetail(this, iPacket);
                    break;

                case GameOpcodes.EVENT_ITEM_BUY_CHECK_REQ:
                    MyShop.CheckItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_BUY_VIRTUAL_CASH_REQ:
                    MyShop.BuyVP(this, iPacket);
                    break;

                case GameOpcodes.EVENT_BUY_FOR_GP_REQ:
                    MyShop.BuyGP(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CHARISMAS_EVENT_INFO_REQ:
                    MyCommon.Event_Gifts(this);
                    break;

                case GameOpcodes.EVENT_CHECK_ROOM_USERLIST_NOT:
                    CurrentRoom.checkRoomUser(this);
                    break;

                case GameOpcodes.EVENT_STAT_LOADING_TIME_NOT:
                    CurrentRoom.statLoadingTime(this, iPacket);
                    break;

                case GameOpcodes.EVENT_SPECIAL_REWARD_REQ:
                    CurrentRoom.RewardItem(this, iPacket);
                    break;

                case GameOpcodes.EVENT_DEPOT_CHAR_TAB_INFO_REQ:
                    GachaList.Depot_Char_tab(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GACHA_REWARD_LIST_REQ:
                    GachaList.Gacha_Reward_List(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GACHA_SET_REWARD_LIST_REQ:
                    GachaList.Gacha_SET_Reward_List(this, iPacket);
                    break;

                case GameOpcodes.EVENT_GACHA_LEVEL_ACTION_REQ:
                    GachaList.Gacha_Action(this, iPacket);
                    break;

                case GameOpcodes.EVENT_REMOVE_MISSION_REQ:
                    MyQuests.RemoveMission(this, iPacket);
                    break;

                case GameOpcodes.EVENT_REGIST_MISSION_REQ:
                    MyQuests.RegisterMission(this, iPacket);
                    break;

                case GameOpcodes.EVENT_COMPLETE_MISSION_REQ:
                    MyQuests.CompleteMission(this, iPacket);
                    break;

                case GameOpcodes.EVENT_CREATE_PET_REQ:
                    MyPet.create_pet(this, iPacket);
                    break;

                case GameOpcodes.EVENT_HERO_ITEM_CATALOG_REQ:
                    heroico.Hero_Item_Catalog(this);
                    break;

                case GameOpcodes.EVENT_HERO_ITEM_MATERIAL_REQ:
                    heroico.Hero_Item_Material(this);
                    break;

                case GameOpcodes.EVENT_MANUFACTURES3_CATALOG_REQ:
                    manufacture.Manufacture_Catalog(this);
                    break;

                case GameOpcodes.EVENT_SPECIFIC_ITEM_BREAKUP_INFO_REQ:
                    manufacture.SpecificItemBreakup(this);
                    break;

                case GameOpcodes.EVENT_MANUFACTURES3_MATERIAL_REQ:
                    manufacture.ManuFactureMaterial(this);
                    break;

                case GameOpcodes.EVENT_DUNGEON_REWARD_EXP_REQ:
                    CurrentRoom.RewardEXP(this, iPacket);
                    break;

                case GameOpcodes.EVENT_USER_LIST_REQ:
                    MyUser.ListUsers(this);
                    break;

                default:
                {
                    LogFactory.GetLog("Main").LogWarning("pacote indefinido foi recebida. Opcode: {0}({1})", (int)uOpcode, uOpcode.ToString());
                    LogFactory.GetLog("Main").LogHex("Pacote: ", iPacket.ToArray());
                    break;
                }
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLog("Main").LogError(e.ToString());
                Close();
            }
        }