private void CWCDisconnected(TCP.WorkerClient sender) { Logger.MajorInfo("Console client disconnected."); sender.TermClient(); consoleCurCons -= 1; curMsg = null; }
private void CWCMessageArrived(WorkerClient sender, byte[] b, int len) { Message.Message msg = new Message.Message(b); try { if (curMsg == null) { Logger.MajorVerbose("Client: " + sender.ClientIP() + System.Environment.NewLine + "Request: " + msg.MessageData); Logger.MajorDebug("Searching for implementor of " + msg.MessageData + "..."); ConsoleCommands.ConsoleCommandClass CC = CCE.GetLoadedCommand(msg.MessageData); if (CC == null) { Logger.MajorError("No implementor for " + msg.MessageData + "."); sender.send("Command not found" + System.Environment.NewLine); } curMsg = (ConsoleCommands.AConsoleCommand)Activator.CreateInstance(CC.CommandType); curMsg.InitializeStack(); } else { string returnMsg = null; try { returnMsg = curMsg.AcceptMessage(msg.MessageData); } catch (Exception ex) { returnMsg = ex.Message; } if ((returnMsg != null) && (curMsg.CommandFinished)) { sender.send(returnMsg + System.Environment.NewLine); curMsg = null; } else { sender.send(curMsg.GetClientMessage()); } return; } if (curMsg.IsNoinputCommand()) { try { sender.send(curMsg.ProcessMessage() + System.Environment.NewLine); } catch (Exception ex) { sender.send(ex.Message); } } } catch (Exception ex) { Logger.MajorError("Exception while parsing message or creating implementor instance" + System.Environment.NewLine + ex.ToString()); Logger.MajorError("Disconnecting client."); sender.TermClient(); curMsg = null; } }