public void parseContent(String content, String ender, Socket handler, StateObject state) { int endlineIndex = content.IndexOf(ender); String statusXml = Schemas.CRCL.Utils.ToXML(status); Console.WriteLine("Status XML:"); Console.WriteLine(statusXml); Console.WriteLine(""); while (endlineIndex > -1) { String line = content.Substring(0, endlineIndex + ender.Length); Console.WriteLine("Read {0} bytes from socket. \n Data : {1}", line.Length, line); // Echo the data back to the client. // Send(handler, line); Send(handler, statusXml); content = content.Substring(endlineIndex + ender.Length); Schemas.CRCL.CommandInstance.CRCLCommandInstanceType cmdInstanceRecvd = Schemas.CRCL.Utils.FromXML <Schemas.CRCL.CommandInstance.CRCLCommandInstanceType> (line); if (null != cmdInstanceRecvd && null != cmdInstanceRecvd.CRCLCommand && !typeof(Schemas.CRCL.CommandInstance.GetStatusType).IsAssignableFrom(cmdInstanceRecvd.CRCLCommand.GetType())) { handleNewCommand(cmdInstanceRecvd); } endlineIndex = content.IndexOf(ender); } state.sb.Clear(); state.sb.Append(content); }
private static void handleNewCommand(Schemas.CRCL.CommandInstance.CRCLCommandInstanceType newCmdInstance) { cmdInstance.CRCLCommand = newCmdInstance.CRCLCommand; }