public StreamObject(StreamObjectType type, string content, StreamObjectThreadType threadType, string topic, IPEndPoint endPoint = null) { this.type = type; this.content = content; this.threadType = threadType; this.topic = topic; this.endPoint = endPoint; }
public void createListerSocket() { System.Collections.Specialized.StringCollection InStreamArray = Properties.Settings.Default.INPUT_STREAM; foreach (string s in InStreamArray) { string[] parse = s.Split('|'); if (parse.Length == 4) { StreamObjectType type = 0; StreamObjectThreadType threadType = 0; if (parse[2].Equals("S")) { threadType = StreamObjectThreadType.SINGLE; } else if (parse[2].Equals("M")) { threadType = StreamObjectThreadType.MULTI; } if (parse[0].Equals("FILE")) { type = StreamObjectType.FILE; InStreamList.Add(new StreamObject(type, parse[1], threadType, parse[3])); } else if (parse[0].Equals("SOCKET")) { type = StreamObjectType.SOCKET; string[] parseAddr = parse[1].Split(':'); IPHostEntry ipHost = Dns.GetHostEntry(parseAddr[0]); IPAddress ipAddr = ipHost.AddressList[1]; IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, Int32.Parse(parseAddr[1])); //통신 소켓 생성 TcpListener listener = new TcpListener(ipEndPoint); socketMap.Add(ipEndPoint, listener); InStreamList.Add(new StreamObject(type, parse[1], threadType, parse[3], ipEndPoint)); } } else { logger.Error("EXCEPTION : Configuration Wrong"); } } }
public void createStreamMapByConfig(System.Collections.Specialized.StringCollection source, List <StreamObject> dest) { foreach (String s in source) { string[] parse = s.Split('|'); if (parse.Length == 4) { StreamObjectType type = 0; StreamObjectThreadType threadType = 0; if (parse[2].Equals("S")) { threadType = StreamObjectThreadType.SINGLE; } else if (parse[2].Equals("M")) { threadType = StreamObjectThreadType.MULTI; } if (parse[0].Equals("FILE")) { type = StreamObjectType.FILE; dest.Add(new StreamObject(type, parse[1], threadType, parse[3])); } else if (parse[0].Equals("SOCKET")) { type = StreamObjectType.SOCKET; string[] parseAddr = parse[1].Split(':'); IPHostEntry ipHost = Dns.GetHostEntry(parseAddr[0]); IPAddress ipAddr = ipHost.AddressList[1]; IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, Int32.Parse(parseAddr[1])); //통신 소켓 생성 TcpClient sender = new TcpClient(); socketMap.Add(ipEndPoint, sender); dest.Add(new StreamObject(type, parse[1], threadType, parse[3], ipEndPoint)); } } else { logger.Error("EXCEPTION : Configuration Wrong"); } } }