public static SocketManager getInstance(string [] data, MsgEventHandler msgHandler) { if (instance == null) { lock (syncRoot) { if (instance == null) { instance = new SocketManager(data, msgHandler); } } } else { logger.Info("already exist SocketManager singleton instance..."); } return(instance); }
public MainForm() { dataTableMap = new Dictionary <string, DataTable>(); //logger check logger.Info("Start App..."); orderLogger.Info("ORDER PROC !!!"); filledLogger.Info("Filled PROC !!!"); rejectLogger.Info("Reject PROC !!!"); string ipMapPath = @"conf_iptable.conf"; msgEventHandler = new MsgEventHandler(this); try { SocketManager sockMgr = SocketManager.getInstance(System.IO.File.ReadAllLines(ipMapPath, Encoding.Default), msgEventHandler); } catch (Exception e) { logger.Error(string.Format("file not found error {0} {1}", ipMapPath, e.ToString())); } view1 = new View1(this); view2 = new View2(this); InitializeComponent(); }
private SocketManager(string[] data, MsgEventHandler msgHandler) { this.msgHandler = msgHandler; messageQueue_0374 = new Queue <STRUCT_0374>(); messageQueue_0374_reply = new Queue <STRUCT_0374_REPLY>(); messageQueue_0393 = new Queue <STRUCT_0393>(); messageQueue_0419 = new Queue <STRUCT_0419>(); socketLogger.Info("Create SocketManager singleton instance..."); socketLogger.Info("ip table loading"); foreach (string s in data) { try { string[] temp = s.Split('|'); if (!iptable.ContainsKey(temp[0])) { string sockID = temp[0]; string addr = temp[1]; string[] parseAddr = addr.Split(':'); IPHostEntry ipHost = Dns.GetHostEntry(parseAddr[0]); IPAddress ipAddr = ipHost.AddressList[1]; IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, Int32.Parse(parseAddr[1])); iptable.Add(sockID, ipEndPoint); } else { logger.Error("socket id duplicate"); } } catch (Exception e) { logger.Error(e.ToString()); } } }