We've discussed firing the PlayerDisconnectedEvent from several locations.
After some testing I've come to the conclusion it might not be very ideal.
I've implemented the hook in the ConnectionManager and in the GameManager.
In the GameManager I get a nice set of information which can be used, but in the ConnectionManager I can't gather this information.
See the log output below generated by a customized version of the PlayerDisconnectedEventListener:
=======[ START DISCONNECT EVENT ]=======
Handled 2/3/2015 8:45:53 PM
Origin GameManager
Entity Id 171
Client Id 1
Player 'GWM' disconnected
=======[ END DISCONNECT EVENT ]=======
=======[ START DISCONNECT EVENT ]=======
Handled 2/3/2015 8:45:53 PM
Origin ConnectionManager
Entity Id 0
Client Id 0
EntityPlayer is 'null'
=======[ END DISCONNECT EVENT ]=======
I am unable to retrieve the missing data because the game has disposed the information. I've tried using the following code:
public PlayerDisconnectedEvent(System.Object[] args)
{
if (args == null || args.Length < 2)
throw new ArgumentNullException("args", "The minimum amount of arguments weren't passed for the PlayerDisconnectedEvent.");
Origin = (EventOrigin)Enum.Parse(typeof(EventOrigin), args[0].ToString());
if (Origin == EventOrigin.GameManager)
{
if (args == null || args.Length < 4)
throw new ArgumentNullException("args", "The minimum amount of arguments weren't passed for the PlayerDisconnectedEvent");
ClientId = (int)args[1];
EntityId = (int)args[2];
EntityPlayer = (EntityPlayer)args[3];
}
else if (Origin == EventOrigin.ConnectionManager)
{
NetworkPlayer information = (NetworkPlayer)args[1];
EntityPlayer = SKMain.getPlayerEntity(information);
if (EntityPlayer == null)
{
return;
}
var clientInfo = SKMain.getClientInfo(EntityPlayer.name);
if (clientInfo == null)
{
return;
}
ClientId = clientInfo.clientId;
EntityId = clientInfo.entityId;
}
}
Right now I think I should drop the event hook from the ConnectionManager because it only provides the following information:
external ip 192.168.178.16
external port 26900
ip 192.168.178.16
port 57188
And this information is also present in the hook from the GameManager.
Currently the hook doesn't provide the NetworkPlayer instance, but I could include it in the call.
Please let me know what you think, and I'll modify it.
We've discussed firing the PlayerDisconnectedEvent from several locations.
After some testing I've come to the conclusion it might not be very ideal.
I've implemented the hook in the ConnectionManager and in the GameManager.
In the GameManager I get a nice set of information which can be used, but in the ConnectionManager I can't gather this information.
See the log output below generated by a customized version of the PlayerDisconnectedEventListener:
I am unable to retrieve the missing data because the game has disposed the information. I've tried using the following code:
Right now I think I should drop the event hook from the ConnectionManager because it only provides the following information:
And this information is also present in the hook from the GameManager.
Currently the hook doesn't provide the NetworkPlayer instance, but I could include it in the call.
Please let me know what you think, and I'll modify it.