static void ClientState(Server s, Client c, bool open)
{
if (open)
{
c.Value = new UserState();
if (!string.IsNullOrEmpty(MOTD))
{
byte[] data = Packer.Serialize((byte)ServerPacket.MOTD, MOTD);
c.Send(data);
}
}
else
{
if (c.Value.Authenticated)
{
byte[] data = Packer.Serialize((byte)ServerPacket.UserLeave, c.Value.UserId);
Broadcast(c.Value.Channel, data);
AwardPoints(c);
//Let's save the users data.
MySqlCommand q = new MySqlCommand(string.Empty, SQL);
q.CommandText = "UPDATE users SET Points=@Points,Rank=@Rank,Mute=@Mute WHERE Username=@Username;";
q.Parameters.AddWithValue("@Points", c.Value.Points);
q.Parameters.AddWithValue("@Rank", c.Value.Rank);
q.Parameters.AddWithValue("@Mute", c.Value.Mute);
q.Parameters.AddWithValue("@Username", c.Value.Username);
//If it fails there isn't much we can do about it.
q.ExecuteNonQuery();
}
}
}