Skip to content

Commit

Permalink
Merge pull request #8 from PokeD/master
Browse files Browse the repository at this point in the history
Fixed stuff
  • Loading branch information
jianmingyong committed Jan 12, 2016
2 parents 38a791b + 1076bcc commit 5a4f830
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Pokemon.3D.Server.Core/Pokemon.3D.Server.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<Compile Include="RCON_GUI_Client_Listener\Servers\Listener.cs" />
<Compile Include="SCON_Client_Listener\SCON\SCONClient.cs" />
<Compile Include="SCON_Client_Listener\SCON\SCONClient.Packets.cs" />
<Compile Include="SCON_Client_Listener\Servers\Listener.cs" />
<Compile Include="SCON_Client_Listener\Servers\ModuleSCON.cs" />
<Compile Include="Shared\Aragas\WrapperInstances\TCPClientWrapperInstance.cs" />
<Compile Include="Shared\Aragas\WrapperInstances\TCPServerWrapperInstance.cs" />
<Compile Include="Server_Client_Listener\Commands\CommandCollection.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public partial class SCONClient
public SCONClient(ITCPClient clientWrapper, ModuleSCON server)
{
Stream = new ProtobufStream(clientWrapper);
Module = (ModuleSCON) server;
Module = server;

AuthorizationStatus = (EncryptionEnabled ? AuthorizationStatus.EncryprionEnabled : 0);
}
Expand All @@ -69,8 +69,7 @@ public void Update()
else
{
Core.Logger.Log($"Protobuf Reading Error: Packet Length size is 0. Disconnecting.");
SendPacket(new AuthorizationDisconnectPacket { Reason = "Packet Length size is 0!" });
Module.RemoveClient(this);
Module.RemoveClient(this, "Packet Length size is 0!");
}
}
}
Expand Down Expand Up @@ -108,8 +107,7 @@ private void HandleData(byte[] data)
else
{
Core.Logger.Log($"SCON Reading Error: Packet ID {id} is not correct, Packet Data: {data}. Disconnecting.");
SendPacket(new AuthorizationDisconnectPacket { Reason = $"Packet ID {id} is not correct!" });
Module.RemoveClient(this);
Module.RemoveClient(this, $"Packet ID {id} is not correct!");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading;

using Aragas.Core.Wrappers;

using PokeD.Core.Packets.SCON.Authorization;
using Pokemon_3D_Server_Core.SCON_Client_Listener.SCON;
using Pokemon_3D_Server_Core.Server_Client_Listener.Loggers;
using Pokemon_3D_Server_Core.Shared.jianmingyong.Modules;
Expand Down Expand Up @@ -69,7 +69,16 @@ private void CheckListener()


public void AddClient(SCONClient client) { Clients.Add(client); }
public void RemoveClient(SCONClient client, string reason = "") { Clients.Remove(client); }

public void RemoveClient(SCONClient client, string reason = "")
{
Clients.Remove(client);

if(!string.IsNullOrEmpty(reason))
client.SendPacket(new AuthorizationDisconnectPacket { Reason = reason });

client.Dispose();
}


private void Update()
Expand Down Expand Up @@ -99,7 +108,7 @@ public void Dispose()

Clients.Clear();

Core.Logger.Log("SCON Listener Disposed.", Logger.LogTypes.Info);
Core.Logger.Log("SCON Listener Disposed.");
}
}
}

0 comments on commit 5a4f830

Please sign in to comment.