void Disconnect() { if (Conn == null) { return; } Conn.UnregisterListener(); Conn = null; }
void Connect(string hostname, int port, string password) { if (Conn != null) { Disconnect(); } Conn = new SamRevAPI(hostname, port, password); Conn.OnDataReceive += new SamRevAPI.OnDataReceiveDelegate(Conn_OnDataReceive); Conn.RegisterListener(); labelStatus.Text = "Connected"; connectToolStripMenuItem.Enabled = false; disconnectToolStripMenuItem.Enabled = true; }