Connect() public method

Runs the websocket connection for the client hooking up the appropriate events.
public Connect ( bool useDotNetWebsocket = false ) : void
useDotNetWebsocket bool If true, DiscordSharp will connect using the .Net Framework's built-in WebSocketClasses. /// Please do not use this on Mono or versions of Windows below 8/8.1
return void
Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            if (!App.ClientConfiguration.Settings.UseWindows10Notifications)
            {
                notificationIcon = new NotifyIcon();
                notificationIcon.Text = "Dissonance";
                notificationIcon.Visible = true;
                notificationIcon.Icon = CustomDiscordClient.Properties.Resources.taskbar;
                notificationIcon.BalloonTipIcon = ToolTipIcon.None;
            }

            Icon = new BitmapImage(MagicalDiscordIcon);
            //channelsList.Visibility = Visibility.Hidden;

            MainClient = new DiscordClient();
            MainClient.RequestAllUsersOnStartup = true;

            SetupEvents();

            Title = "Dissonance - Connecting..";
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            if(MainClient.SendLoginRequest() != null)
                discordTask = Task.Run(() => MainClient.Connect());

            openServerViews = new List<ServerView>();

            SettingsGearClicked += MainWindow_SettingsGearClicked;

            SetupTheme();
        }
        public MainWindow()
        {
            InitializeComponent();

            #if WIN10NOTIF
            #else
            notificationIcon = new NotifyIcon();
            notificationIcon.Text = "WPF Discord";
            notificationIcon.Visible = true;
            notificationIcon.Icon = CustomDiscordClient.Properties.Resources.taskbar;
            notificationIcon.BalloonTipIcon = ToolTipIcon.None;
            #endif

            Icon = new BitmapImage(MagicalDiscordIcon);
            //channelsList.Visibility = Visibility.Hidden;

            MainClient = new DiscordClient();
            MainClient.RequestAllUsersOnStartup = true;

            SetupEvents();

            Title = "Connecting..";
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            if(MainClient.SendLoginRequest() != null)
                discordTask = Task.Run(() => MainClient.Connect());

            openServerViews = new List<ServerView>();

            SetupTheme();
        }
Exemplo n.º 3
0
 static Task ClientTask(DiscordClient client)
 {
     return Task.Run(() =>
     {
         client.MessageReceived += (sender, e) =>
         {
             if (e.message.content.StartsWith("?joinvoice"))
             {
                 string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                 if (split[1] != "")
                 {
                     DiscordChannel toJoin = e.Channel.parent.channels.Find(x => (x.Name.ToLower() == split[1].ToLower()) && (x.Type == ChannelType.Voice));
                     if (toJoin != null)
                     {
                         client.ConnectToVoiceChannel(toJoin);
                     }
                 }
             }
             else if (e.message.content.StartsWith("?voice"))
             {
                 string[] split = e.message.content.Split(new char[] { ' ' }, 2);
                 if (File.Exists(split[1]))
                     DoVoice(client.GetVoiceClient(), split[1]);
             }
             else if(e.message.content.StartsWith("?disconnect"))
             {
                 client.DisconnectFromVoice();
             }
         };
         client.Connected += (sender, e) =>
         {
             Console.WriteLine("Connected as " + e.user.Username);
         };
         client.Connect();
     });
 }