/// <summary> /// Function returning the strategy, based on order type. /// </summary> /// <param name="received">The entire HTTP message sent with the request</param> /// <param name="BasePath">Path to directory containing the desc.xml files for descriptions</param> /// <param name="pub">The instance of publisher containing all subscribers, used for eventing</param> /// <returns></returns> public IRespondStrategy GetStrategy(string received, string BasePath, Publisher pub) { IRespondStrategy strategy = null; string[] splitter = new string[] { "\r\n" }; string[] StrArr = received.Split(splitter, StringSplitOptions.None); string order = StrArr[0]; if (TCPDebug.DEBUG) { Console.WriteLine("Order: " + order); Console.WriteLine(received); } string[] eq = order.Split(' '); switch (eq[0]) { case "GET": strategy = new GETResponder(BasePath + eq[1]); break; case "POST": strategy = new POSTResponder(received); break; case "SUBSCRIBE": strategy = new SubscribeResponder(pub,received); break; default: Console.WriteLine("Error in Switch-case:"); Console.WriteLine (eq[0]); Console.WriteLine(order); break; } return strategy; }
//Why??? //Todo: Remove, maybe??? public TCPHandle(string BasePath, IIpConfig ipConf) { _basePath = BasePath; _pub = new Publisher(ipConf); }