You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-15 22:56:30 +09:00
MasterServerSample slightly working but wholly untested
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.comboBox1 = new System.Windows.Forms.ComboBox();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
@@ -68,12 +69,12 @@
|
||||
this.comboBox1.FormattingEnabled = true;
|
||||
this.comboBox1.Location = new System.Drawing.Point(15, 44);
|
||||
this.comboBox1.Name = "comboBox1";
|
||||
this.comboBox1.Size = new System.Drawing.Size(499, 200);
|
||||
this.comboBox1.Size = new System.Drawing.Size(499, 122);
|
||||
this.comboBox1.TabIndex = 4;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(241, 250);
|
||||
this.button2.Location = new System.Drawing.Point(241, 172);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(273, 23);
|
||||
this.button2.TabIndex = 5;
|
||||
@@ -81,11 +82,23 @@
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.richTextBox1.Location = new System.Drawing.Point(15, 201);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.Size = new System.Drawing.Size(499, 106);
|
||||
this.richTextBox1.TabIndex = 6;
|
||||
this.richTextBox1.Text = "";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(528, 289);
|
||||
this.ClientSize = new System.Drawing.Size(528, 319);
|
||||
this.Controls.Add(this.richTextBox1);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.comboBox1);
|
||||
this.Controls.Add(this.label1);
|
||||
@@ -106,6 +119,7 @@
|
||||
public System.Windows.Forms.Label label1;
|
||||
public System.Windows.Forms.ComboBox comboBox1;
|
||||
public System.Windows.Forms.Button button2;
|
||||
public System.Windows.Forms.RichTextBox richTextBox1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace MSClient
|
||||
m_hostList = new List<IPEndPoint[]>();
|
||||
|
||||
NetPeerConfiguration config = new NetPeerConfiguration("game");
|
||||
config.SetMessageTypeEnabled(NetIncomingMessageType.UnconnectedData, true);
|
||||
config.EnableMessageType(NetIncomingMessageType.UnconnectedData);
|
||||
config.EnableMessageType(NetIncomingMessageType.NatIntroductionSuccess);
|
||||
m_client = new NetClient(config);
|
||||
m_client.Start();
|
||||
|
||||
@@ -43,6 +44,12 @@ namespace MSClient
|
||||
{
|
||||
switch (inc.MessageType)
|
||||
{
|
||||
case NetIncomingMessageType.VerboseDebugMessage:
|
||||
case NetIncomingMessageType.DebugMessage:
|
||||
case NetIncomingMessageType.WarningMessage:
|
||||
case NetIncomingMessageType.ErrorMessage:
|
||||
NativeMethods.AppendText(m_mainForm.richTextBox1, inc.ReadString());
|
||||
break;
|
||||
case NetIncomingMessageType.UnconnectedData:
|
||||
if (inc.SenderEndpoint.Equals(m_masterServer))
|
||||
{
|
||||
@@ -56,7 +63,8 @@ namespace MSClient
|
||||
}
|
||||
break;
|
||||
case NetIncomingMessageType.NatIntroductionSuccess:
|
||||
MessageBox.Show("Nat introduction success; I just received a message from " + inc.SenderEndpoint);
|
||||
string token = inc.ReadString();
|
||||
MessageBox.Show("Nat introduction success to " + inc.SenderEndpoint + " token is: " + token);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +104,7 @@ namespace MSClient
|
||||
// write external address of host to request introduction to
|
||||
IPEndPoint hostEp = new IPEndPoint(NetUtility.Resolve(host), CommonConstants.GameServerPort);
|
||||
om.Write(hostEp);
|
||||
om.Write("randomtoken");
|
||||
om.Write("mytoken");
|
||||
|
||||
m_client.SendUnconnectedMessage(om, m_masterServer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user