public ChatManager(ConsoleBotInstance botInstance) { m_Client = botInstance.Client; m_objManager = botInstance.ObjEvtManager; m_actionManager = new ActionManager(botInstance); m_Client.Self.ChatFromSimulator += new EventHandler<ChatEventArgs>(OnChatFromSimulator); // m_Sensor = new Sensor("jl2", "user2", botInstance.NetManager.Password, Constant.NODE_PERCEPT); m_Sensor = new Sensor("jl2", botInstance.NetManager.Username + "_client", botInstance.NetManager.Password, botInstance.NetManager.Username + "_percept"); m_Sensor.SensorCreateEvent += new SensorCreateEventHandler(OnSensorCreateEvent); }
// // // private bool DoNextBehaviour(float distToDest, float distToSelf, bool bDisabled) { bool result = false; ActionManager am = new ActionManager(m_botInstance); if (bDisabled == true) { if (distToDest < distToSelf) { am.InvokeAction(Action.GoBack); } else { Console.WriteLine("waiting for additional movement"); } } else { if (distToSelf > distToDest) { // enable social force // enable Inter-Personal distance behaviours } } return result; }
/* public void OnSubscribeHandler(object sender, MessageEventArgs e) { ActionManager am = new ActionManager(this); Action action = Action.None; JsonReading jr = new JsonReading(); jr.fromJSON(e.Message.ToString()); JsonReading.Value val = jr.FindValue("ACTION"); Debug.WriteLine(val.m_obj.ToString()); action = am.GetAction(val.m_obj.ToString()); am.InvokeAction(action); } */ /* * Legacy code - XMPP message handler supported by Jabber-net library. * This is no longer needed, but left in order for the reference how message handling works. * Also, helps what operations should be carried out in the message handler. * // XMPP Message handling and perfoming actions public void JabberReadMsg(object sender, Message msg) { ActionManager am = new ActionManager(this); Action action = Action.None; if (msg.From == "nohannara" || msg.From.ToString().Contains("mind")) { // ignore keep-alive message if (msg.Body != " ") { Console.WriteLine("RECV: " + msg.Body); //m_sensorClient.sendMessage("user2" + "@jlnetbook/smack", "Got it: " + msg.Body); action = am.GetAction(msg.Body); am.InvokeAction(action); } } else { string name = m_Client.Self.FirstName; string target = "mind" + name.ElementAt(name.Length - 1) + "@jlnetbook/smack"; m_sensor.sendMessage(target, msg.Body); } } */ public void Run() { string cmd; ActionManager am = new ActionManager(this); Action action = Action.None; if (m_netManager.Login() == true) { cmd = Console.ReadLine(); action = am.GetAction(cmd); while (action != Action.Logout) { am.InvokeAction(action); cmd = Console.ReadLine(); action = am.GetAction(cmd); } if (action == Action.Logout) { m_netManager.Logout(); } } }