1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-15 22:56:30 +09:00

masterserver sample work

This commit is contained in:
lidgren
2010-05-11 20:42:58 +00:00
parent e62057c250
commit 6afb80ab12
6 changed files with 23 additions and 3 deletions

View File

@@ -33,6 +33,15 @@ namespace Lidgren.Network
{
private static Regex s_regIP;
/// <summary>
/// Get IP endpoint from notation (xxx.xxx.xxx.xxx) or hostname and port number
/// </summary>
public static IPEndPoint Resolve(string ipOrHost, int port)
{
IPAddress adr = Resolve(ipOrHost);
return new IPEndPoint(adr, port);
}
/// <summary>
/// Get IP address from notation (xxx.xxx.xxx.xxx) or hostname
/// </summary>

View File

@@ -23,7 +23,7 @@ namespace MSClient
private void button2_Click(object sender, EventArgs e)
{
string host = comboBox1.SelectedText;
string host = comboBox1.SelectedItem.ToString();
Program.RequestNATIntroduction(host);
}
}

View File

@@ -52,9 +52,12 @@ namespace MSClient
m_hostList.Add(new IPEndPoint[] { hostInternal, hostExternal });
m_mainForm.comboBox1.Items.Add(hostExternal.ToString());
m_mainForm.comboBox1.Items.Add(hostExternal.Address.ToString());
}
break;
case NetIncomingMessageType.NatIntroductionSuccess:
MessageBox.Show("Nat introduction success; I just received a message from " + inc.SenderEndpoint);
break;
}
}
}
@@ -93,6 +96,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");
m_client.SendUnconnectedMessage(om, m_masterServer);
}

View File

@@ -45,7 +45,7 @@ namespace MasterServer
msg.ReadIPEndpoint(), // internal
msg.SenderEndpoint // external
};
Console.WriteLine("Registered host " + eps[1]);
Console.WriteLine("Got registration for host " + eps[1]);
registeredHosts.Add(eps);
break;
@@ -83,6 +83,7 @@ namespace MasterServer
msg.SenderEndpoint, // client external
token // request token
);
Console.WriteLine("Sending...");
break;
}
}

View File

@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSClient", "MSClient\MSClie
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSCommon", "MSCommon\MSCommon.csproj", "{DCD2BE10-1B14-4C80-8BD6-77A8B1F43346}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSServer", "MSServer\MSServer.csproj", "{BBE12F3E-098F-4C13-842F-A52B86E2611A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -31,6 +33,10 @@ Global
{DCD2BE10-1B14-4C80-8BD6-77A8B1F43346}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DCD2BE10-1B14-4C80-8BD6-77A8B1F43346}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DCD2BE10-1B14-4C80-8BD6-77A8B1F43346}.Release|Any CPU.Build.0 = Release|Any CPU
{BBE12F3E-098F-4C13-842F-A52B86E2611A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BBE12F3E-098F-4C13-842F-A52B86E2611A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBE12F3E-098F-4C13-842F-A52B86E2611A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBE12F3E-098F-4C13-842F-A52B86E2611A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE