Exemple #1
0
        protected override async Task OnInitializeAsync(IActivatedEventArgs args)
        {
            // Models
            var audioManager = new Models.AudioPlaybackManager();
            await audioManager.Initialize();

            Container.RegisterInstance(audioManager);
            Container.RegisterInstance(new Models.DiscordContext(audioManager));

            // ViewModels
            Container.RegisterInstance(Container.Resolve <ViewModels.MenuViewModel>());


            // Setup discord voice processing.
            Discord.Audio.Streams.OpusDecodeStream.OpusDecoderFactory = () => new Models.OpusDecoderImpl();
            Discord.Audio.Streams.OpusEncodeStream.OpusEncodeFactory  = (bitrate, app, signal) => new Models.OpusEncoderImpl(bitrate, app, signal);
            Discord.Audio.Streams.SodiumDecryptStream.StreamCipher    = Models.SodiumImpl.Instance;
            Discord.Audio.Streams.SodiumEncryptStream.StreamCipher    = Models.SodiumImpl.Instance;

            // 自動ログインを行う
            var discordContext = Container.Resolve <Models.DiscordContext>();
            await discordContext.TryLoginWithRecordedCredential();

            await base.OnInitializeAsync(args);
        }
Exemple #2
0
        public DiscordContext(AudioPlaybackManager audioManager)
        {
            AudioManager = audioManager;

            _Guilds = new ObservableCollection <SocketGuild>();
            Guilds  = _Guilds.ToReadOnlyReactiveCollection();

            _CurrentGuildTextChannels = new ObservableCollection <SocketTextChannel>();
            CurrentGuildTextChannels  = new ReadOnlyObservableCollection <SocketTextChannel>(_CurrentGuildTextChannels);

            _CurrentGuildVoiceChannels = new ObservableCollection <SocketVoiceChannel>();
            CurrentGuildVoiceChannels  = new ReadOnlyObservableCollection <SocketVoiceChannel>(_CurrentGuildVoiceChannels);



            // this is unkode(durty code).
            // IMessage.Contentの内容をMarkdownに変換する際、
            // ユーザーIDからユーザー名を引きたいためにこんなことをしてます
            // Model上で解決すべき?
            Views.Controls.DiscordMessageContent.UserIdToUserName = UserIdToUserName;
        }