You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-19 08:36:34 +09:00
masterserver sample work
This commit is contained in:
@@ -33,6 +33,15 @@ namespace Lidgren.Network
|
|||||||
{
|
{
|
||||||
private static Regex s_regIP;
|
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>
|
/// <summary>
|
||||||
/// Get IP address from notation (xxx.xxx.xxx.xxx) or hostname
|
/// Get IP address from notation (xxx.xxx.xxx.xxx) or hostname
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace MSClient
|
|||||||
|
|
||||||
private void button2_Click(object sender, EventArgs e)
|
private void button2_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string host = comboBox1.SelectedText;
|
string host = comboBox1.SelectedItem.ToString();
|
||||||
Program.RequestNATIntroduction(host);
|
Program.RequestNATIntroduction(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,9 +52,12 @@ namespace MSClient
|
|||||||
|
|
||||||
m_hostList.Add(new IPEndPoint[] { hostInternal, hostExternal });
|
m_hostList.Add(new IPEndPoint[] { hostInternal, hostExternal });
|
||||||
|
|
||||||
m_mainForm.comboBox1.Items.Add(hostExternal.ToString());
|
m_mainForm.comboBox1.Items.Add(hostExternal.Address.ToString());
|
||||||
}
|
}
|
||||||
break;
|
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
|
// write external address of host to request introduction to
|
||||||
IPEndPoint hostEp = new IPEndPoint(NetUtility.Resolve(host), CommonConstants.GameServerPort);
|
IPEndPoint hostEp = new IPEndPoint(NetUtility.Resolve(host), CommonConstants.GameServerPort);
|
||||||
om.Write(hostEp);
|
om.Write(hostEp);
|
||||||
|
om.Write("randomtoken");
|
||||||
|
|
||||||
m_client.SendUnconnectedMessage(om, m_masterServer);
|
m_client.SendUnconnectedMessage(om, m_masterServer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace MasterServer
|
|||||||
msg.ReadIPEndpoint(), // internal
|
msg.ReadIPEndpoint(), // internal
|
||||||
msg.SenderEndpoint // external
|
msg.SenderEndpoint // external
|
||||||
};
|
};
|
||||||
Console.WriteLine("Registered host " + eps[1]);
|
Console.WriteLine("Got registration for host " + eps[1]);
|
||||||
registeredHosts.Add(eps);
|
registeredHosts.Add(eps);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -83,6 +83,7 @@ namespace MasterServer
|
|||||||
msg.SenderEndpoint, // client external
|
msg.SenderEndpoint, // client external
|
||||||
token // request token
|
token // request token
|
||||||
);
|
);
|
||||||
|
Console.WriteLine("Sending...");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSClient", "MSClient\MSClie
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSCommon", "MSCommon\MSCommon.csproj", "{DCD2BE10-1B14-4C80-8BD6-77A8B1F43346}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSCommon", "MSCommon\MSCommon.csproj", "{DCD2BE10-1B14-4C80-8BD6-77A8B1F43346}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSServer", "MSServer\MSServer.csproj", "{BBE12F3E-098F-4C13-842F-A52B86E2611A}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{DCD2BE10-1B14-4C80-8BD6-77A8B1F43346}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user