// This initializes the server with fake data so that views are not empty when loaded. // This assumes that the current user is connected to the system. public static void Init() { if (_initializedFakeData) { return; } Client.Register(BuildAuthenticationMessage(), session => { _user1Session = session; Client.Connect(_user1Session, c => { SetupUser1(); Client.Disconnect(); Client.Register(BuildAuthenticationMessage(), session2 => { _user2Session = session2; Client.Connect(_user2Session, c2 => { SetupUser2(); Client.Disconnect(); Client.Register(BuildAuthenticationMessage(), session3 => { _user3Session = session3; Client.Connect(_user3Session, c3 => { SetupUser3(); Client.Disconnect(); SetupMainUser(); _initializedFakeData = true; }); }, ErrorHandler); }); }, ErrorHandler); }); }, ErrorHandler); }
private void btnConnect_Click(object sender, EventArgs e) { tbxStatus.Text = "Connecting ... "; port = GetPort(); if (port == 0) { MessageBox.Show("The port is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ip = GetIP(); if (ip == IPAddress.None) { MessageBox.Show("The IP address is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Nclient = new NClient(ip, port); Nclient.SetMessage = new NClient.SetTextToControl(SetMessage); Nclient.SetStatus = new NClient.SetTextToControl(SetStatus); Nclient.Connect(); }