public void SetiBOT(AIMLBot.iBOT intelligentBOT) { _iBot = intelligentBOT; }
/// <summary> /// Ctor /// </summary> /// <param name="bot">The bot for whom this is a settings dictionary</param> public SettingsDictionary(AIMLBot bot) { this.Bot = bot; }
/// <summary> /// Starts the server in an infinite loop waiting for connections. /// </summary> public static void Start() { //1. Start the API endpoint. try { WebApp.Start <Startup>(url: ApiBaseUrl); Console.WriteLine(" API Server endpoint started on URL " + ApiBaseUrl); } catch (Exception ex) { Console.WriteLine(string.Concat("ERROR: Could not start the API server endpoint. Possibly a permissions issue." , Environment.NewLine, ex.Message, Environment.NewLine , "If you are on a Windows machine, try running this command as an Administrator:", Environment.NewLine , "netsh http add urlacl url=http://*:8880/ user=Everyone listen=yes", Environment.NewLine , "Don't forget to change the port number (8880 above) as per your App.config settings.")); } //2. Setup the Bot engine and start the TCP server AIMLBot myBot = new AIMLBot(); try { myBot.LoadSettings(); myBot.LoadAIMLFromFiles(); } catch (Exception ex) { Console.WriteLine(string.Concat(ex.Message, Environment.NewLine, "Could not load the bot settings and/or AIML files. ", "Please ensure that config and aiml folders exist in the same directory as your .exe file or the directory as per your configuration." )); Environment.Exit(0); } Users = new Dictionary <string, BotUser>(); Guid defaultId = Guid.NewGuid(); BotUser myUser = new BotUser(defaultId, myBot); DefaultUser = myUser; Users[defaultId.ToString()] = myUser; myBot.IsAcceptingInput = false; myBot.IsAcceptingInput = true; ActiveBot = myBot; TcpListener serverSocket = new TcpListener(IPAddress, Port); TcpClient clientSocket = default(TcpClient); int counter = 0; serverSocket.Start(); Console.WriteLine(" Karmaloop AIML Bot Server Started on port " + Port.ToString()); Console.WriteLine("---------------------------------------------------------------- "); Console.WriteLine(); Console.WriteLine("Take the bot for a spin! Try hitting the URL http://localhost:8880/api/ChatUi/index.html from your local browser!"); counter = 0; while (!ForceStop) { counter += 1; clientSocket = serverSocket.AcceptTcpClient(); Console.WriteLine(" >> " + "Client No:" + Convert.ToString(counter) + " started!"); KarmaloopClient client = new KarmaloopClient(); client.StartClient(clientSocket, Convert.ToString(counter)); } }