private Thread connectThread; // Thread variable public Form1() { InitializeComponent(); //Classes.User.InitializeDB(); Classes.DBLogging.InitializeDB(); connectThread = new Thread(new ThreadStart(ConnectThread)); // Make instance of the thread and assign method name which will be executed in the thread // listView1 setup listView1.View = View.Details; // Shows the header listView1.FullRowSelect = true; // !!!Lets to select the whole row in the table!!! /* * listView1.GridLines = true; // Horizoltal lines * listView1.Columns.Add("Time:"); * listView1.Columns[0].Width = 60; * listView1.Columns.Add("Source:", -2, HorizontalAlignment.Left); * listView1.Columns.Add("Message:"); * listView1.Columns[2].Width = 400; */ // Create fleck socket server FleckLog.Level = LogLevel.Debug; var allSockets = new List <IWebSocketConnection>(); var server = new WebSocketServer("ws://0.0.0.0:8181"); server.SupportedSubProtocols = new[] { "superchat", "chat" }; server.Start(socket => { socket.OnOpen = () => { //ListViewLogging.log_add(this, "mainListBox", "Form1.cs", "Websocket connection open!", "white"); allSockets.Add(socket); }; socket.OnClose = () => { //ListViewLogging.log_add(this, "mainListBox", "Form1.cs", "Websocket connection closed!", "white"); allSockets.Remove(socket); }; socket.OnMessage = message => { //ListViewLogging.log_add(this, "mainListBox", "Form1.cs onMessage", "Message: " + message, "yellow"); // Send message back to websocket allSockets.ToList().ForEach(s => s.Send("Echo. Hellow from c#: " + message)); }; }); db = new Classes.User(1, "1", "1"); }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { ListViewItem item = listView1.SelectedItems[0]; currUser = (Classes.User)item.Tag; int id = currUser.Id; String u = currUser.Username; String p = currUser.Password; txtUsername.Text = u; txtId.Text = id.ToString(); txtPassword.Text = p; } }