Example #1
0
 /// <summary>
 /// Closes the connection to the server. Triggers FindBeacon to start back up.
 /// </summary>
 public void CloseConnection()
 {
     if (tcpConn != null)
     {
         if (tcpConn.Connected)
         {
             //NetworkCommand nc = new NetworkCommand(NetworkCommand.CommandTypes.KillKey);
             KillKey k = new KillKey(clientMAC, "");
             //nc.MacAddress = clientMAC;
             SendMessage(k.ToJson());
             try
             {
                 tcpConn.Client.Shutdown(SocketShutdown.Send);
             }
             catch (IOException) { }
             clientThread.Abort();
             clientNS.Close();
             tcpConn.Close();
             hasConnection = false;
             EntryOutput(">> Connection closed.");
             beaconThread = new Thread(o => FindBeacon());
         }
     }
     else
     {
         tcpConn      = null;
         clientThread = null;
         clientNS     = null;
         EntryOutput(">> No existing connection.");
     }
 }