private bool logIn() { string user = "******"; string pass = "******"; Command tcmd = new CommandLogin(user, pass); cmdTrans.sendCmd(tcmd); tcmd = cmdTrans.getCmd(); if (tcmd.GetType().Equals(typeof(CommandAccept))) { return(true); } else { return(false); } }
public void runReceiver() { CancellationTokenRegistration ctr = token.Register(CancelAsync); Command cmd; while (!token.IsCancellationRequested) { try { cmd = cmdTrans.getCmd(); if (!cmd.Equals(null)) { /*if(cmdProc.ID.Equals("")) * Console.WriteLine("CH *new*: Received command: " + cmd.GetType()); * else * Console.WriteLine("CH " + cmdProc.ID + ": Received command: " + cmd.GetType());*/ cmdProc.Incoming.Add(cmd, token); } } catch (SocketException se) { if (se.ErrorCode.Equals(10054)) { break; } } catch (Exception e) { Console.WriteLine("CH " + cmdProc.ID + ": Receiver: " + e.Message); if (e.Message.Equals("Not responding")) { break; } } } if (socket.Connected) { socket.Shutdown(SocketShutdown.Both); socket.Close(); } if (!token.IsCancellationRequested) { cts.Cancel(); } ctr.Dispose(); Console.WriteLine("CH " + cmdProc.ID + ": Receiver: Client handler thread has ended"); }