void EmitCloseAndDisconnect()
 {
     if (Socket.State != WebSocketState.Open)
     {
         return;                                      //We can't close a session that is not connected
     }
     //this is ran outside of the send queue as it is already being cancelled
     Task.Run(async() =>
     {
         try
         {
             await WritePacketToSIOSocketAsync(Encoder.Encode(new SocketPacket(EnginePacketType.MESSAGE, SocketPacketType.DISCONNECT, 0, "/", -1, "")), CancellationToken.None);
             //await WritePacketToSIOSocketAsync(Encoder.Encode(new SocketPacket(EnginePacketType.CLOSE)), CancellationToken.None);
             if (Socket.State == WebSocketState.Open)
             {
                 await Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "normal disconnect", CancellationToken.None);                                      //Usually the server closes the connection but if not... We'll do this cleanly.
             }
         }
         catch (Exception e)
         {
             SocketIOManager.LogWarning("Could not cleanly close Socket.IO connection: " + e.ToString());
         }
         RaiseSIOEvent("close");
     });
 }
 void EmitPacket(SocketPacket packet)
 {
     sendQueue.Add(new Tuple <DateTime, string>(DateTime.UtcNow, Encoder.Encode(packet)));
 }