/// <summary> /// Initializes a new instance of the <see cref="ChatWindow"/> class. /// </summary> /// <param name="user"> /// The user to chat with. /// </param> /// <param name="networking"> /// The networking. /// </param> public ChatWindow(UserClass user, ref Networking networking) { InitializeComponent(); this.friend = user; UserLabel.Content += user.UserName; this.net = networking; }
public MainWindow(Networking networking) { InitializeComponent(); //App.FillUser(ref App.User); this.net = networking; // App.TaskFortress.StartNew(this.OnlineLinqList, net); //System.Threading.Thread onThread = new Thread(o => // { // onlineList = this.OnlineLinqList(o); // }); //System.Threading.Thread offThread = new Thread(o => //{ // offlineList = this.OfflineLinqList(o); //}); //var on = net.TheUser.Friends.Where(@class => @class.LoggedIn == true).ToList(); //var off = net.TheUser.Friends.Where(@class => @class.LoggedIn == false).ToList(); onThread.Start(net); offThread.Start(net); onThread.Join(); this.OnlineList.ItemsSource = onlineList; offThread.Join(); this.OfflineList.ItemsSource = offlineList; this.LogInText.Text += net.TheUser.UserName; }
/// <summary> /// The button login click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void BtnLoginClick(object sender, RoutedEventArgs e) { var user = new UserClass(this.TxtUsername.Text, this.TxtPassword.Password, false); var result = false; var networking = new Networking(user); // AsyncNetworkCaller asyncNetwork = LoginThread; // asyncNetwork.BeginInvoke(networking, Callback, null); //asyncNetwork.Invoke() var login = new Thread(() => { result = LoginThread(networking); }) { Name = "Login thread" }; login.Start(); login.Join(); // Networking networking = new Networking(); if (!result) { return; } var main = new MainWindow(networking); main.Show(); this.Close(); }
/// <summary> /// Initializes a new instance of the <see cref="AddFriends"/> class. /// </summary> /// <param name="networking"> /// The networking. /// </param> // TODO pass by ref public AddFriends(ref Networking networking) { InitializeComponent(); this.net = networking; }
/// <summary> /// Method to register the user. For use by threading to prevent UI thread blocking. /// </summary> /// <returns> /// Returns whether the registration was successful. /// </returns> private bool Reg() { var net = new Networking(this.user); var result = false; try { result = net.Register(user); } catch { } finally { net.CloseNetwork(); } running = false; return result; }
/// <summary> /// The send packet. /// </summary> /// <param name="packet"> /// The packet. /// </param> /// <param name="net"> /// The net. /// </param> private void SendPacket(Packet packet, Networking network) { network.SendMessage(packet); this.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new UpdateUserInterfaceDelegate(this.UpdateUserInterface), packet); }
/// <summary> /// The login. /// </summary> /// <param name="net"> /// The net. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> private static bool LoginThread(Networking net) { return net.Login(net.TheUser); }