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

MasterServer sample fixed

This commit is contained in:
lidgren
2012-09-13 07:10:52 +00:00
parent fd224b88d8
commit af4f77a8a5
5 changed files with 12 additions and 19 deletions

View File

@@ -93,7 +93,6 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@@ -51,11 +51,11 @@ namespace MSClient
NativeMethods.AppendText(m_mainForm.richTextBox1, inc.ReadString());
break;
case NetIncomingMessageType.UnconnectedData:
if (inc.SenderEndpoint.Equals(m_masterServer))
if (inc.SenderEndPoint.Equals(m_masterServer))
{
// it's from the master server - must be a host
IPEndPoint hostInternal = inc.ReadIPEndpoint();
IPEndPoint hostExternal = inc.ReadIPEndpoint();
IPEndPoint hostInternal = inc.ReadIPEndPoint();
IPEndPoint hostExternal = inc.ReadIPEndPoint();
m_hostList.Add(new IPEndPoint[] { hostInternal, hostExternal });
@@ -64,7 +64,7 @@ namespace MSClient
break;
case NetIncomingMessageType.NatIntroductionSuccess:
string token = inc.ReadString();
MessageBox.Show("Nat introduction success to " + inc.SenderEndpoint + " token is: " + token);
MessageBox.Show("Nat introduction success to " + inc.SenderEndPoint + " token is: " + token);
break;
}
}

View File

@@ -105,9 +105,6 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -99,9 +99,6 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -42,8 +42,8 @@ namespace MasterServer
// It's a host wanting to register its presence
IPEndPoint[] eps = new IPEndPoint[]
{
msg.ReadIPEndpoint(), // internal
msg.SenderEndpoint // external
msg.ReadIPEndPoint(), // internal
msg.SenderEndPoint // external
};
Console.WriteLine("Got registration for host " + eps[1]);
registeredHosts.Add(eps);
@@ -51,24 +51,24 @@ namespace MasterServer
case MasterServerMessageType.RequestHostList:
// It's a client wanting a list of registered hosts
Console.WriteLine("Sending list of " + registeredHosts.Count + " hosts to client " + msg.SenderEndpoint);
Console.WriteLine("Sending list of " + registeredHosts.Count + " hosts to client " + msg.SenderEndPoint);
foreach (IPEndPoint[] ep in registeredHosts)
{
// send registered host to client
NetOutgoingMessage om = peer.CreateMessage();
om.Write(ep[0]);
om.Write(ep[1]);
peer.SendUnconnectedMessage(om, msg.SenderEndpoint);
peer.SendUnconnectedMessage(om, msg.SenderEndPoint);
}
break;
case MasterServerMessageType.RequestIntroduction:
// It's a client wanting to connect to a specific (external) host
IPEndPoint clientInternal = msg.ReadIPEndpoint();
IPEndPoint hostExternal = msg.ReadIPEndpoint();
IPEndPoint clientInternal = msg.ReadIPEndPoint();
IPEndPoint hostExternal = msg.ReadIPEndPoint();
string token = msg.ReadString();
Console.WriteLine(msg.SenderEndpoint + " requesting introduction to " + hostExternal + " (token " + token + ")");
Console.WriteLine(msg.SenderEndPoint + " requesting introduction to " + hostExternal + " (token " + token + ")");
// find in list
foreach (IPEndPoint[] elist in registeredHosts)
@@ -81,7 +81,7 @@ namespace MasterServer
elist[0], // host internal
elist[1], // host external
clientInternal, // client internal
msg.SenderEndpoint, // client external
msg.SenderEndPoint, // client external
token // request token
);
break;