private void Connect(object sender, RoutedEventArgs e)
        {
            var user = txtUser.Text.Trim();

            if (string.IsNullOrEmpty(user))
            {
                return;
            }

            CurrentUser = user;

            btnIn.IsEnabled = false;
            btnIn.Content   = "Connecting";

            Task.Run(() =>
            {
                var chatCallback         = new ChatCallBack(user);
                chatCallback.OnSayHello += MainWindow_OnSayHello;
                chatCallback.OnLogin    += MyCallBack_OnLogin;
                chatCallback.OnLogout   += ChatCallback_OnLogout;

                proxy = ProxyFactory.CreateChatServerProxy(chatCallback);
                proxy.RegisterClient();

                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    btnSend.IsEnabled = true;
                    btnIn.Content     = "Connected";
                }));
            });
        }
        public static ChatServerProxy CreateChatServerProxy(ChatCallBack chatCallback)
        {
            var context = new InstanceContext(chatCallback);
            var proxy   = new ChatServerProxy(context, EndpointConfigurationName);

            return(proxy);
        }