added CDiscover: searching the network for running vocaluxe server, could be useful for users who do not know what a ip address is.

This commit is contained in:
Alexander Eckart committed 2013-05-10 16:44:19 +02:00
1 parent 74af5ae691
commit b18c688936
8 files changed
+192

No files matched your search

+39
View File
@@ -49,6 +49,9 @@
this.btDown = new System.Windows.Forms.Button();
this.btSendAvatar = new System.Windows.Forms.Button();
this.btSendProfile = new System.Windows.Forms.Button();
this.btDiscover = new System.Windows.Forms.Button();
this.tbDiscoveredServer = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
@@ -251,11 +254,44 @@
this.btSendProfile.UseVisualStyleBackColor = true;
this.btSendProfile.Click += new System.EventHandler(this.btSendProfile_Click);
//
// btDiscover
//
this.btDiscover.Location = new System.Drawing.Point(831, 502);
this.btDiscover.Name = "btDiscover";
this.btDiscover.Size = new System.Drawing.Size(165, 23);
this.btDiscover.TabIndex = 16;
this.btDiscover.Text = "Discover";
this.btDiscover.UseVisualStyleBackColor = true;
this.btDiscover.Click += new System.EventHandler(this.btDiscover_Click);
//
// tbDiscoveredServer
//
this.tbDiscoveredServer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbDiscoveredServer.Location = new System.Drawing.Point(15, 405);
this.tbDiscoveredServer.Multiline = true;
this.tbDiscoveredServer.Name = "tbDiscoveredServer";
this.tbDiscoveredServer.Size = new System.Drawing.Size(810, 120);
this.tbDiscoveredServer.TabIndex = 17;
this.tbDiscoveredServer.WordWrap = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 389);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 13);
this.label1.TabIndex = 18;
this.label1.Text = "Server:";
//
// ClientTest
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1008, 550);
this.Controls.Add(this.label1);
this.Controls.Add(this.tbDiscoveredServer);
this.Controls.Add(this.btDiscover);
this.Controls.Add(this.btSendProfile);
this.Controls.Add(this.btSendAvatar);
this.Controls.Add(this.btDown);
@@ -307,6 +343,9 @@
private System.Windows.Forms.Button btDown;
private System.Windows.Forms.Button btSendAvatar;
private System.Windows.Forms.Button btSendProfile;
private System.Windows.Forms.Button btDiscover;
private System.Windows.Forms.TextBox tbDiscoveredServer;
private System.Windows.Forms.Label label1;
}
}
+21
View File
@@ -19,12 +19,15 @@ namespace ClientTest
public partial class ClientTest : Form
{
CClient client;
CDiscover discover;
private bool loggedIn;
public ClientTest()
{
client = new CClient();
loggedIn = false;
discover = new CDiscover(3000, CCommands.BroadcastKeyword);
InitializeComponent();
}
@@ -32,6 +35,7 @@ namespace ClientTest
protected override void OnClosing(CancelEventArgs e)
{
client.Close();
discover.Stop();
base.OnClosing(e);
}
@@ -262,5 +266,22 @@ namespace ClientTest
client.SendMessage(CCommands.CreateCommandSendProfile(data, "TestUser", 0), OnResponse);
}
}
private void btDiscover_Click(object sender, EventArgs e)
{
tbDiscoveredServer.Text = "Searching for Vocaluxe Server:\r\n";
discover.Discover(_OnDiscovered);
}
private void _OnDiscovered(string Address, string HostName)
{
this.Invoke((MethodInvoker)delegate
{
if (Address != "Timeout")
tbDiscoveredServer.Text += "IP = " + Address + "; HostName = " + HostName + "\r\n";
else
tbDiscoveredServer.Text += "Timeout" + "\r\n";
});
}
}
}