Skip to content

Commit

Permalink
Cleaning up setting chat and login servers
Browse files Browse the repository at this point in the history
  • Loading branch information
dragagon committed Sep 2, 2011
1 parent 572e314 commit 03e2ef9
Show file tree
Hide file tree
Showing 35 changed files with 20,962 additions and 41 deletions.
43 changes: 35 additions & 8 deletions CJRGaming.MMO/CJRGaming.MMO.5.1.ReSharper.user
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
</SettingsComponent>
<RecentFiles>
<RecentFiles>
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:MasterServer.cs" caret="151" fromTop="6" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncommingSubServerPeer.cs" caret="761" fromTop="0" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncomingSubServerPeer.cs" caret="2102" fromTop="33" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:MasterServer.cs" caret="2639" fromTop="24" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="2946" fromTop="25" />
</RecentFiles>
<RecentEdits>
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:MasterServer.cs" caret="280" fromTop="13" />
Expand All @@ -19,12 +20,20 @@
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:MasterServer.cs" caret="986" fromTop="32" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:MasterServer.cs" caret="716" fromTop="20" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:MasterServer.cs" caret="151" fromTop="6" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncommingSubServerPeer.cs" caret="908" fromTop="14" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncommingSubServerPeer.cs" caret="301" fromTop="11" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncommingSubServerPeer.cs" caret="1241" fromTop="31" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncommingSubServerPeer.cs" caret="1392" fromTop="27" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncommingSubServerPeer.cs" caret="542" fromTop="21" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:IncommingSubServerPeer.cs" caret="761" fromTop="30" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1491" fromTop="25" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1491" fromTop="21" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1491" fromTop="30" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="2063" fromTop="39" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1491" fromTop="47" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="4201" fromTop="45" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="3722" fromTop="38" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1325" fromTop="24" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1249" fromTop="20" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1104" fromTop="15" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="1489" fromTop="28" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="2063" fromTop="27" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="2512" fromTop="37" />
<File id="1628E9EF-28A9-49FB-A17A-BF7163926189/d:MasterServer/f:SubServerCollection.cs" caret="2946" fromTop="25" />
</RecentEdits>
</RecentFiles>
<NAntValidationSettings>
Expand All @@ -41,6 +50,24 @@
<CompletionStatisticsManager>
<ItemStatistics item="Default">
<Item value="NodeResolverBase`0" priority="0" />
<Item value="if" priority="3" />
<Item value="id" priority="1" />
<Item value="ChatServer" priority="3" />
<Item value="null" priority="2" />
<Item value="LoginServer" priority="1" />
<Item value="public" priority="0" />
<Item value="void" priority="0" />
<Item value="ResetServers`0" priority="0" />
<Item value="SubServerCollection`0" priority="0" />
<Item value="IncomingSubServerPeer`0" priority="0" />
<Item value="peer" priority="1" />
</ItemStatistics>
<ItemStatistics item="Qualified:CJRGaming.MMO.Server.MasterServer.IncomingSubServerPeer">
<Item value="ServerId" priority="1" />
<Item value="Type" priority="0" />
</ItemStatistics>
<ItemStatistics item="Qualified:@CJRGaming.MMO.Server.MasterServer.SubServerType">
<Item value="Chat" priority="0" />
</ItemStatistics>
</CompletionStatisticsManager>
</Configuration>
18 changes: 17 additions & 1 deletion CJRGaming.MMO/CJRGaming.MMO.Server/CJRGaming.MMO.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,29 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MasterServer\IncommingSubServerPeer.cs" />
<Compile Include="MasterServer\IncomingSubServerPeer.cs" />
<Compile Include="MasterServer\MasterServer.cs" />
<Compile Include="MasterServer\MasterServerSettings1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>MasterServerSettings.settings</DependentUpon>
</Compile>
<Compile Include="MasterServer\SubServerCollection.cs" />
<Compile Include="MasterServer\SubServerType.cs" />
<Compile Include="Operations\ErrorCode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Server2Server\Operations\OperationCodes.cs" />
<Compile Include="Server2Server\Operations\RegisterSubServer.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="SubServer\" />
</ItemGroup>
<ItemGroup>
<None Include="MasterServer\MasterServerSettings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>MasterServerSettings1.Designer.cs</LastGenOutput>
</None>
</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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,20 @@ public void OnConnect(IncomingSubServerPeer gameServerPeer)
{
peer.Disconnect();
Remove(id);
// We just removed a server, we need to see if it is a chat or login server, and if it was, null it out.
if (id == ChatServer.ServerId)
{
ChatServer = null;
}
if (id == LoginServer.ServerId)
{
LoginServer = null;
}
}

Add(id, gameServerPeer);

// 1) If we support the Chat type and the chat server is empty OR
// 2) if we are a full chat server and the current chat server does more than one thing
// Make this the chat server.
if (((gameServerPeer.Type & SubServerType.Chat) == SubServerType.Chat && ChatServer == null || ChatServer.ServerId == null) ||

(gameServerPeer.Type == SubServerType.Chat && (ChatServer.Type & SubServerType.Region) == SubServerType.Region ||
(ChatServer.Type & SubServerType.Login) == SubServerType.Login))
{
ChatServer = gameServerPeer;
}
// 1) If we support the Login type and the login server is empty OR
// 2) if we are a full login server and the current login server does more than one thing
// Make this the login server.
if(((gameServerPeer.Type & SubServerType.Login) == SubServerType.Login && LoginServer == null || LoginServer.ServerId == null) ||

(gameServerPeer.Type == SubServerType.Login && (LoginServer.Type & SubServerType.Region) == SubServerType.Region ||
(LoginServer.Type & SubServerType.Chat) == SubServerType.Chat))
{
LoginServer = gameServerPeer;
}
ResetServers();
}
}

Expand All @@ -75,20 +65,48 @@ public void OnDisconnect(IncomingSubServerPeer gameServerPeer)
if (peer == gameServerPeer)
{
Remove(id);
// We just removed a server, we need to see if it is a chat or login server, and if it was, we need to find a new one.
if(id == ChatServer.ServerId)
// We just removed a server, we need to see if it is a chat or login server, and if it was, null it out.
if (id == ChatServer.ServerId)
{
ChatServer = Values.Where(subServerPeer => subServerPeer.Type == SubServerType.Chat).FirstOrDefault() ??
Values.Where(subServerPeer => (subServerPeer.Type & SubServerType.Chat) == SubServerType.Chat).FirstOrDefault();
ChatServer = null;
}

if (id == LoginServer.ServerId)
{
LoginServer = Values.Where(subServerPeer => subServerPeer.Type == SubServerType.Login).FirstOrDefault() ??
Values.Where(subServerPeer => (subServerPeer.Type & SubServerType.Login) == SubServerType.Login).FirstOrDefault();
LoginServer = null;
}
ResetServers();
}
}
}

public void ResetServers()
{
if(ChatServer != null && ChatServer.Type != SubServerType.Chat)
{
IncomingSubServerPeer peer =
Values.Where(subServerPeer => subServerPeer.Type == SubServerType.Chat).FirstOrDefault();
if(peer != null)
{
ChatServer = peer;
}
}
// We just removed a server, we need to see if it is a chat or login server, and if it was, we need to find a new one.
if (ChatServer == null || ChatServer.ServerId == null)
{
// Check if there is a full chat server in the list of servers
ChatServer = Values.Where(subServerPeer => subServerPeer.Type == SubServerType.Chat).FirstOrDefault() ??
// If no full chat server exists, find one that supports the chat server.
Values.Where(subServerPeer => (subServerPeer.Type & SubServerType.Chat) == SubServerType.Chat).FirstOrDefault();
}

if (LoginServer == null || LoginServer.ServerId == null)
{
// Check if there is a full login server in the list of servers
LoginServer = Values.Where(subServerPeer => subServerPeer.Type == SubServerType.Login).FirstOrDefault() ??
// If no full login server exists find one that supports the chat server.
Values.Where(subServerPeer => (subServerPeer.Type & SubServerType.Login) == SubServerType.Login).FirstOrDefault();
}

}

#endregion
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 03e2ef9

Please sign in to comment.