Skip to content

Instantly share code, notes, and snippets.

@Noxalus
Created September 6, 2013 16:10
Show Gist options
  • Save Noxalus/6466060 to your computer and use it in GitHub Desktop.
Save Noxalus/6466060 to your computer and use it in GitHub Desktop.
Lidgren cut the disconnect string.
NetIncomingMessage incMsg;
NetConnection sender;
while ((incMsg = server.ReadMessage()) != null)
{
sender = incMsg.SenderConnection;
Client t_client = clients.GetClientFromConnection(sender);
switch (incMsg.MessageType)
{
case NetIncomingMessageType.StatusChanged:
if (sender.Status == NetConnectionStatus.Connected)
{
// Some instructions
}
else if (sender.Status != NetConnectionStatus.Connected)
{
if (t_client != null)
{
WriteOutput("[Disconnected]Client " + t_client.ClientId + " has disconnected (" + incMsg.ReadString + ")");
clients.RemoveClient(t_client);
OnDisconnectedClient(t_client, new EventArgs());
}
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment