Ejemplo n.º 1
0
        void Client_OnMatchComplete(object sender, MatchResult e)
        {
            this.Invoke((Action)(() =>
            {
                var extra = e.Extra;
                if (string.IsNullOrEmpty(extra))
                {
                    extra = string.Format("Found: {0}, MemberId: {1}, Elapsed: {2}", e.Found, e.MemberId, DateTime.Now - e.RequestDate);
                }

                if (queue.Count > 0) //e.Extra != null && e.Extra.Contains("Run time:"))
                {
                    var elapsed = DateTime.Now - e.RequestDate;

                    RichTextBoxConsole.AppendText(String.Format("{0}" + Environment.NewLine, extra) +
                                                  String.Format("Elapsed: {0}" + Environment.NewLine, elapsed));

                    totalElapsed += elapsed;
                    EventHandler handler = OnMatch;
                    if (handler != null)
                    {
                        handler(this, null);
                    }
                }
                else
                {
                    RichTextBoxConsole.AppendText(Environment.NewLine + String.Format("{0}", extra));
                }
            }));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates and connects the hub connection and hub proxy. This method
        /// is called asynchronously from SignInButton_Click.
        /// </summary>
        private async void ConnectAsync()
        {
            Connection         = new HubConnection(ServerURI);
            Connection.Closed += Connection_Closed;
            HubProxy           = Connection.CreateHubProxy("MyHub");
            //Handle incoming event from server: use Invoke to write to console from SignalR's thread
            HubProxy.On <string, string>("AddMessage", (name, message) =>
                                         this.Dispatcher.Invoke(() =>
                                                                RichTextBoxConsole.AppendText(String.Format("{0}: {1}\r", name, message))
                                                                )
                                         );
            try
            {
                await Connection.Start();
            }
            catch (HttpRequestException)
            {
                StatusText.Content = "Unable to connect to server: Start server before connecting clients.";
                //No connection: Don't enable Send button or show chat UI
                return;
            }

            //Show chat UI; hide login UI
            SignInPanel.Visibility = Visibility.Collapsed;
            ChatPanel.Visibility   = Visibility.Visible;
            ButtonSend.IsEnabled   = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + "\r");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates and connects the connection. Only uses one controller (chat). This method
        /// is called from SignInButton_Click.
        /// </summary>
        private async void Connect()
        {
            Connection = new XSocketClient(ServerURI, Origin, "chat");
            Connection.OnDisconnected += Connection_Disconnected;
            chatController             = Connection.Controller("chat");

            //Handle incoming event from server: use Invoke to write to console from XSocket's thread
            chatController.On <string>("addMessage", message => this.Invoke((Action)(() =>
                                                                                     RichTextBoxConsole.AppendText(String.Format("{0}" + Environment.NewLine, message))
                                                                                     )));

            try
            {
                Connection.Open();
                comboBoxLocation.SelectedIndex = 0;
                //Set username
                chatController.SetProperty("username", UserName);
            }
            catch
            {
                StatusText.Text = "Unable to connect to server: Start server before connecting clients.";
                //No connection: Don't enable Send button or show chat UI
                return;
            }

            //Activate UI
            SignInPanel.Visible = false;
            ChatPanel.Visible   = true;
            ButtonSend.Enabled  = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + Environment.NewLine);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates and connects the hub connection and hub proxy. This method
        /// is called asynchronously from SignInButton_Click.
        /// </summary>
        private async void ConnectAsync()
        {
            Connection = new XSocketClient(ServerURI, Origin, "chat");
            Connection.OnDisconnected += Connection_Disconnected;
            chatController             = Connection.Controller("chat");

            //Handle incoming event from server: use Invoke to write to console from XSocket's thread
            chatController.On <string>("AddMessage", (message) =>
                                       this.Dispatcher.Invoke(() =>
                                                              RichTextBoxConsole.AppendText(String.Format("{0}\r", message))
                                                              )
                                       );

            try
            {
                await Connection.Open();

                //Set username
                await chatController.SetProperty("username", UserName);
            }
            catch
            {
                StatusText.Content = "Unable to connect to server: Start server before connecting clients.";
                //No connection: Don't enable Send button or show chat UI
                return;
            }

            //Show chat UI; hide login UI
            SignInPanel.Visibility = Visibility.Collapsed;
            ChatPanel.Visibility   = Visibility.Visible;
            ButtonSend.IsEnabled   = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + "\r");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates and connects the hub connection and hub proxy. This method
        /// is called asynchronously from SignInButton_Click.
        /// </summary>
        private async void ConnectAsync()
        {
            Console.WriteLine("Connecting to {0}", ServerURI);

            Connection         = new HubConnectionBuilder().WithUrl(ServerURI).Build();
            Connection.Closed += Connection_Closed;
            //HubProxy = Connection.Create("MyHub");
            //Handle incoming event from server: use Invoke to write to console from SignalR's thread
            Connection.On <string, string>("Send", (name, message) =>
                                           this.Invoke((Action)(() =>
                                                                RichTextBoxConsole.AppendText(String.Format("{0}: {1}" + Environment.NewLine, name, message))
                                                                ))
                                           );
            try
            {
                await Connection.StartAsync();
            }
            catch (HttpRequestException)
            {
                StatusText.Text = "Unable to connect to server: Start server before connecting clients.";
                //No connection: Don't enable Send button or show chat UI
                return;
            }

            //Activate UI
            SignInPanel.Visible = false;
            ChatPanel.Visible   = true;
            ButtonSend.Enabled  = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + Environment.NewLine);
        }
        private async void ConnectAsync()
        {
            Connection         = new HubConnection(ServerUri);
            Connection.Closed += Connection_Closed;

            // 创建一个集线器代理对象
            HubProxy = Connection.CreateHubProxy("ChatHub");

            // 供服务端调用,将消息输出到消息列表框中
            HubProxy.On <string, string>("AddMessage", (name, message) =>
                                         this.Dispatcher.Invoke(() =>
                                                                RichTextBoxConsole.AppendText(String.Format("{0}: {1}\r", name, message))
                                                                ));

            try
            {
                await Connection.Start();
            }
            catch (HttpRequestException)
            {
                ChatPanel.Visibility = Visibility.Visible;
                RichTextBoxConsole.AppendText("请检查服务是否开启:" + ServerUri + "\r");
                // 连接失败
                return;
            }

            // 显示聊天控件
            ChatPanel.Visibility = Visibility.Visible;
            ButtonSend.IsEnabled = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("连上服务:" + ServerUri + "\r");
        }
Ejemplo n.º 7
0
        private async void ConnectAsync()
        {
            Connection         = new HubConnection(ServerURI);
            Connection.Closed += Connection_Closed;
            HubProxy           = Connection.CreateHubProxy("MyHub");

            HubProxy.On <string, string>("AddMessage", (name, message) =>
            {
                Invoke((Action)(() =>
                                RichTextBoxConsole.AppendText(string.Format("{0}: {1}" + Environment.NewLine, name, message))
                                ));
                string Path = PathSaved + "\\" + DateTime.Now.ToLongDateString() + new Random().Next(214421414) + ".txt";
                using (StreamWriter writer = new StreamWriter(Path))
                {
                    writer.Write(Name + ":" + message);
                }
            }

                                         );
            try
            {
                await Connection.Start();
            }
            catch (HttpRequestException)
            {
                StatusText.Text = "Unable to connect to server: Start server before connecting clients.";

                return;
            }

            SignInPanel.Visible = false;
            ChatPanel.Visible   = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + Environment.NewLine);
        }
Ejemplo n.º 8
0
        private void cmdSendTasks_Click(object sender, EventArgs e)
        {
            var request = new MatchRequest(MatchManager.Cache.Fingerprints[MatchManager.LocaleId][1]); //LastFingerprint);

            request.ExtraRefCode = 123;
            RichTextBoxConsole.AppendText(Environment.NewLine + String.Format("{0}", "Request sent"));
            client.IdentifyAsync(request);
        }
Ejemplo n.º 9
0
        //Creates and connects the hub connection and hub proxy.
        //This method is called asynchronously from SignInButton_Click.
        private async void ConnectAsync()
        {
            Connection = new HubConnection(ServerURI, new Dictionary <string, string>
            {
                { "UserName", UserName }
            });

            Connection.Closed       += Connection_Closed;
            Connection.Reconnecting += Connection_Reconnecting;
            Connection.Reconnected  += Connection_Reconnected;

            HubProxy = Connection.CreateHubProxy("ChatHub");

            //Handle incoming event from server: use Invoke to write to console from SignalR's thread
            HubProxy.On <string, string, string>("AddMessage", (name, message, group) =>
                                                 this.Invoke((Action)(() =>
                                                                      //RichTextBoxConsole.AppendText(String.Format("{0}: {1}" + Environment.NewLine, name, message))
                                                                      WriteMessage(name, message, group)
                                                                      ))
                                                 );
            try
            {
                await Connection.Start();
            }
            catch (HttpRequestException)
            {
                StatusText.Text = "Unable to connect to server: Start server before connecting clients.";
                //No connection: Don't enable Send button or show chat UI
                return;
            }
            //State oject stores data to be transmitted to the server
            HubProxy["userName"] = UserName;

            //Activate UI
            lblUserName.Text = UserName;
            lblUserName.Font = new System.Drawing.Font("Arial", 20);

            SignInPanel.Visible = false;
            ChatPanel.Visible   = true;
            //btnSend.Enabled = true;
            //txtMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + Environment.NewLine);

            //var user = _db.Users.Include("Groups").SingleOrDefault(u => u.ID == UserID);

            UpdateGroups();

            lblUserStatus.ForeColor = System.Drawing.Color.Green;
            //VAIHDA
            //foreach (var item in user.Groups)
            //{
            //    //TabPage tp = new TabPage(item.GroupName) { Name = item.GroupName , Tag = item.ID};
            //    //tcGroups.TabPages.Add(tp);
            //    //tp.Controls.Add(new ucChatWindow() {ParentForm = this});

            //    await HubProxy.Invoke("JoinGroup", item.GroupName);
            //}
        }
 /// <summary>
 /// If the server is stopped, the connection will time out after 30 seconds (default), and the
 /// Closed event will fire.
 /// </summary>
 private void Connection_Closed()
 {
     imModel.ConnId = null;
     //Deactivate chat UI; show login UI.
     this.Invoke((Action)(() => {
         RichTextBoxConsole.AppendText("Disconnected to server at " + DateTime.Now.ToLocalTime() + Environment.NewLine);
         ConnectionStatus.Text = "通信连接关闭!";
         ButtonSend.Enabled = false;
     }));
 }
Ejemplo n.º 11
0
 public void method(string key, string message)
 {
     this.Dispatcher.Invoke(() =>
     {
         RichTextBoxConsole.AppendText($"executing {key}: {message}\r\n");
         var response = _resolver.Parse(message);
         RichTextBoxConsole.AppendText($"status {key}: {response.Succeeded}\r\n");
         _clientHubConnectionService.Response(key, response.Succeeded? "Succeeded":response.ErrorMessage);
     });
 }
Ejemplo n.º 12
0
 /// <summary>
 /// This method adds a line to the RichTextBoxConsole control, using Invoke if used
 /// from a SignalR hub thread rather than the UI thread.
 /// </summary>
 /// <param name="message"></param>
 internal void WriteToConsole(String message)
 {
     if (RichTextBoxConsole.InvokeRequired)
     {
         this.Invoke((Action)(() =>
                              WriteToConsole(message)
                              ));
         return;
     }
     RichTextBoxConsole.AppendText(message + Environment.NewLine);
 }
Ejemplo n.º 13
0
 ///This method adds a line to the RichTextBoxConsole control, using Dispatcher.Invoke if used
 /// from a SignalR hub thread rather than the UI thread.
 public void WriteToConsole(String message)
 {
     if (!(RichTextBoxConsole.CheckAccess()))
     {
         this.Dispatcher.Invoke(() =>
                                WriteToConsole(message)
                                );
         return;
     }
     RichTextBoxConsole.AppendText(message + "\r");
 }
        private void Client_NewUserNotification(UserData user)
        {
            this.Dispatcher.Invoke(() =>
            {
                if (Users.Find(i => i.Id == user.Id) == null)
                {
                    Users.Add(user);

                    ShowUserList();

                    RichTextBoxConsole.AppendText("New user arrived: " + user.Name + ". Welcome!\r");
                }
            });
        }
        private void Client_UserDisconnectedNotification(UserData user)
        {
            this.Dispatcher.Invoke(() =>
            {
                UserData u = Users.Find(i => i.Id == user.Id);
                if (u != null)
                {
                    Users.Remove(u);

                    ShowUserList();

                    RichTextBoxConsole.AppendText(user.Name + " left the chat.\r");
                }
            });
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Writes the output to the console control.
        /// </summary>
        /// <param name="output">The output.</param>
        /// <param name="color">The color.</param>
        public void WriteOutput(string output, Color color)
        {
            if (string.IsNullOrEmpty(_lastInput) == false &&
                (output == _lastInput || output.Replace("\r\n", "") == _lastInput))
            {
                return;
            }

            RunOnUiDespatcher(() =>
            {
                //  Write the output.
                RichTextBoxConsole.Selection.ApplyPropertyValue(TextBlock.ForegroundProperty, new SolidColorBrush(color));
                RichTextBoxConsole.AppendText(output);
                RichTextBoxConsole.ScrollToEnd();
            });
        }
Ejemplo n.º 17
0
        private void cmdSendQueue_Click(object sender, EventArgs e)
        {
            var count = Convert.ToInt32(txtQueue.Text.Trim());

            for (int i = 0; i < count; i++)
            {
                var request = new MatchRequest(MatchManager.Cache.Fingerprints[MatchManager.LocaleId][1]);
                request.ExtraRefCode = 321;
                queue.Enqueue(request); //.LastFingerprint));
            }

            totalElapsed = new TimeSpan();
            queueTimer.Restart();
            RichTextBoxConsole.AppendText(Environment.NewLine + String.Format("{0}", "Request sent"));
            client.IdentifyAsync(queue.Dequeue());
        }
        private async void ConnectAsync()
        {
            client = new ChatHub(ServerURI);
            //client.Connection.Closed += Connection_Closed;
            client.Message                      += Client_Message;
            client.Welcome                      += Client_Welcome;
            client.NewUserNotification          += Client_NewUserNotification;
            client.NicknameChangedNotification  += Client_NicknameChangedNotification;
            client.UserDisconnectedNotification += Client_UserDisconnectedNotification;
            bool r = await client.Start();

            if (r == false)
            {
                StatusText.Content = "Unable to connect to server: Start server before connecting clients.";
                return;
            }
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + "\r");
        }
        private void Client_NicknameChangedNotification(UserData user, string oldName)
        {
            this.Dispatcher.Invoke(() =>
            {
                if (user.Id == client.Connection.ConnectionId)
                {
                    LbName.Content = user.Name;
                }

                UserData u = Users.Find(i => i.Id == user.Id);
                if (u != null)
                {
                    u.Name = user.Name;
                    ShowUserList();
                    RichTextBoxConsole.AppendText(oldName + " is now " + user.Name + ".\r");
                }
            });
        }
Ejemplo n.º 20
0
        void WinFormsClient_OnMatch(object sender, EventArgs e)
        {
            if (queue.Count > 0)
            {
                RichTextBoxConsole.AppendText(Environment.NewLine + String.Format("{0}", "Request sent"));
                client.IdentifyAsync(queue.Dequeue());
            }
            else
            {
                if (queueTimer.IsRunning)
                {
                    queueTimer.Stop();
                    RichTextBoxConsole.AppendText("Queue Combined: " + queueTimer.Elapsed);
                    RichTextBoxConsole.AppendText(Environment.NewLine + "Queue Total: " + totalElapsed + Environment.NewLine);

                    queueTimer.Reset();
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Creates and connects the hub connection and hub proxy. This method
        /// is called asynchronously from SignInButton_Click.
        /// </summary>
        private async void ConnectAsync()
        {
            client = new EchoHub(ServerURI);
            client.Connection.Closed += Connection_Closed;
            client.Message           += message =>
            {
                this.Dispatcher.Invoke(() =>
                                       RichTextBoxConsole.AppendText(String.Format("{0}\r", message))
                                       );
            };
            bool r = await client.Start();

            if (r == false)
            {
                StatusText.Content = "Unable to connect to server: Start server before connecting clients.";
                return;
            }
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + "\r");
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Writes the input to the console control.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="color">The color.</param>
        /// <param name="echo">if set to <c>true</c> echo the input.</param>
        public void WriteInput(string input, Color color, bool echo)
        {
            RunOnUiDespatcher(() =>
            {
                //  Are we echoing?
                if (echo)
                {
                    RichTextBoxConsole.Selection.ApplyPropertyValue(TextBlock.ForegroundProperty, new SolidColorBrush(color));
                    RichTextBoxConsole.AppendText(input);
                }

                _lastInput = input;

                //  Write the input.
                _processInterace.WriteInput(input);

                //  Fire the event.
                FireProcessInputEvent(new ProcessEventArgs(input));
            });
        }
Ejemplo n.º 23
0
 private async void ConnectAsync()
 {
     Connection         = new HubConnection(ServerURI);
     Connection.Closed += Connection_Closed;
     HubProxy           = Connection.CreateHubProxy("chatHub");
     HubProxy.On <string, string>("ReceiveMessage", (user, message) =>
                                  this.Dispatcher.Invoke(() =>
                                                         RichTextBoxConsole.AppendText(String.Format("{0}: {1}\r", user, message))
                                                         ));
     try
     {
         await Connection.Start();
     }
     catch (HttpRequestException)
     {
         StatusText.Content = "Unable to connect to server: Start server before connecting clients.";
         //No connection: Don't enable Send button or show chat UI
         return;
     }
     RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + "\r");
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Creates and connects the hub connection and hub proxy. This method
        /// is called asynchronously from SignInButton_Click.
        /// </summary>

        private async void ConnectAsync()
        {
            string ServerURI = String.Empty;

            try
            {
                ServerURI = ServerUriBuilder.GetServerUriForClient(this.textBox1.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Podany adres jest nieprawidłowy. Wyjątek: {ex.Message}");
                return;
            }

            Connection         = new HubConnection(ServerURI);
            Connection.Closed += Connection_Closed;
            HubProxy           = Connection.CreateHubProxy("MyHub");
            //Handle incoming event from server: use Invoke to write to console from SignalR's thread
            HubProxy.On <string, string>("AddMessage", (name, message) =>
                                         this.Invoke((Action)(() =>
                                                              RichTextBoxConsole.AppendText(String.Format("{0} {1}: {2}" + Environment.NewLine, name, DateTime.Now, message))
                                                              ))
                                         );
            try
            {
                await Connection.Start();
            }
            catch (HttpRequestException)
            {
                StatusText.Text = "Unable to connect to server: Start server before connecting clients.";
                //No connection: Don't enable Send button or show chat UI
                return;
            }
            //Activate UI
            SignInPanel.Visible = false;
            ChatPanel.Visible   = true;
            ButtonSend.Enabled  = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + Environment.NewLine);
        }
        /// <summary>
        /// Creates and connects the hub connection and hub proxy. This method
        /// is called asynchronously from SignInButton_Click.
        /// </summary>
        private async void ConnectAsync()
        {
            Dictionary <string, string> hubConnParams = new Dictionary <string, string> {
                { "Param", JsonConvert.SerializeObject(imModel) }
            };

            Connection              = new HubConnection(ServerURI, hubConnParams);
            Connection.Closed      += Connection_Closed;
            Connection.Reconnected += Connection_Succeed;

            HubProxy = Connection.CreateHubProxy("MyHub");
            //Handle incoming event from server: use Invoke to write to console from SignalR's thread
            //HubProxy.On<string, string>("AddMessage", (ServiceName, Data) =>
            //    this.Invoke((Action)(() => {
            //        RichTextBoxConsole.AppendText(String.Format("Service - {0}:\n {1}" + Environment.NewLine, ServiceName, Data));
            //    }))
            //);
            HubProxy.On <string>("AddMessage", doMessage);
            try {
                await Connection.Start();

                imModel.ConnId        = Connection.ConnectionId;
                ConnectionStatus.Text = "服务器连接成功!" + imModel.ConnId;
                btnConnSrv.Text       = "重新连接";
                Connection_Succeed();
            } catch (HttpRequestException e) {
                ConnectionStatus.Text = "服务器连接失败:" + e.Message;
                //No connection: Don't enable Send button or show chat UI
                btnConnSrv.Enabled = true;
                return;
            }

            //Activate UI
            ButtonSend.Enabled = true;
            TextBoxMessage.Focus();
            RichTextBoxConsole.AppendText("Connected to server at " + ServerURI + Environment.NewLine);
        }
 private void Client_Message(string message)
 {
     this.Dispatcher.Invoke(() =>
                            RichTextBoxConsole.AppendText(String.Format("{0}\r", message))
                            );
 }
 private void treeView2_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     RichTextBoxConsole.AppendText("Client " + e.Node.Name + " Clicked by " + DateTime.Now.ToLocalTime() + Environment.NewLine);
     lblModel.Tag  = e.Node.Name;
     lblModel.Text = e.Node.Text;
 }
Ejemplo n.º 28
0
 private void Get_Button_Click(object sender, EventArgs e)//取得所選擇日期的臨時密碼
 {
     RichTextBoxConsole.AppendText(ChooseDate.Text
                                   + " : " + GetTemporaryPassword() + "\n");
 }
Ejemplo n.º 29
0
 private void cmdGetStatus_Click(object sender, EventArgs e)
 {
     RichTextBoxConsole.AppendText(Environment.NewLine + client.GetCacheStatus());
 }
Ejemplo n.º 30
0
        private void SignInButton_Click(object sender, EventArgs e)
        {
            MatchManager.StartupPath = Application.StartupPath;
            //FingerprintMatcher.BenchmarkMode = false;
            RichTextBoxConsole.AppendText("BenchmarkMode: " + MatchManager.BenchmarkMode + Environment.NewLine);

            //Connect to server (use async method to avoid blocking UI thread)
            StatusText.Visible = true;
            StatusText.Text    = "Connecting to server...";

            //client.EnableLocaleCache = false;
            client.LocaleId = DataHelper.GetInt32(ConfigurationManager.AppSettings["LocaleId"]);
            client.Initialize();
            client.EnableLocaleCache = false;

            client.OnMatchComplete += Client_OnMatchComplete;
            OnMatch += WinFormsClient_OnMatch;

            if (client.ClientMode == ClientModes.SignalR)
            {
                client.Connection.Closed += Connection_Closed;

                //Handle incoming event from server: use Invoke to write to console from SignalR's thread

                //client.OnIdentifyComplete((result) =>
                //{
                //    this.Invoke((Action)(() =>
                //    {
                //        if (result.Extra.Contains("Run time:"))
                //        {
                //            var elapsed = DateTime.Now - result.RequestDate;

                //            RichTextBoxConsole.AppendText(String.Format("{0}: {1}" + Environment.NewLine, "", result.Extra) +
                //                String.Format("Elapsed: {0}" + Environment.NewLine + Environment.NewLine, elapsed));

                //            totalElapsed += elapsed;
                //            EventHandler handler = OnMatch;
                //            if (handler != null)
                //                handler(this, null);
                //        }
                //        else
                //        {
                //            RichTextBoxConsole.AppendText(Environment.NewLine + String.Format("{0}: {1}" + Environment.NewLine, "", result.Extra));
                //        }
                //    }));
                //});

                client.HubProxy.On <DateTime, string>("addMessage", (date, message) =>
                {
                    this.Invoke((Action)(() =>
                    {
                        RichTextBoxConsole.AppendText(Environment.NewLine + String.Format("{0}" + Environment.NewLine, message));
                    }));
                });

                RichTextBoxConsole.AppendText("Connected to server at " + client.ServerURI + Environment.NewLine);
            }
            else
            {
                RichTextBoxConsole.AppendText("Ready." + Environment.NewLine);
            }

            //Activate UI
            SignInPanel.Visible = false;
            ChatPanel.Visible   = true;
            //ButtonSend.Enabled = true;
            //TextBoxMessage.Focus();
        }