public Form1() { InitializeComponent(); res = new ResourceManager("iConnectTest.Resource", this.GetType().Assembly); this.timer1.Enabled = true; XmlDocument doc = new XmlDocument(); doc.Load("Config.xml"); XmlNodeList nodes = doc.GetElementsByTagName("Server"); serverid = Convert.ToUInt16(nodes[0].Attributes.GetNamedItem("id").InnerText); cc = (ClientP2P)Communicator.CreateClient(APPID.TestApp2App); cc.updateClientEvent += new Client.updateClientDelegate(cc_updateClientEvent); cc.SendStatusEvent += new Client.SendStatusDelegate(cc_SendStatusEvent); //cc.ReceivedEvent += new Client.ReceiveDelegate(cc_ReceivedEvent); cc.ExceptionEvent += new Client.ExceptionDelegate(cc_ExceptionEvent); for (int i = 0; i < getThreadCount; i++) { getThread.Add(new Thread(GetccData)); } foreach (var v in getThread) { v.IsBackground = true; v.Start(); } }
public static Client CreateClient(APPID App, string ConfigPath) { if (!Clients.ContainsKey(App)) { lock (SynObject) { if (!Clients.ContainsKey(App)) { foreach (var v in Apps) { if (v.id == App) { switch (v.type) { case APPTYPE.App2Res: Client c1 = new ClientApp(v, ConfigPath); Clients.Add(App, c1); break; case APPTYPE.App2App: Client c2 = new ClientP2P(v, ConfigPath); Clients.Add(App, c2); break; case APPTYPE.Res2App: Client c3 = new ClientRes(v, ConfigPath); Clients.Add(App, c3); break; case APPTYPE.Authorization: Client c4 = new ClientAuthor(v, ConfigPath); Clients.Add(App, c4); break; case APPTYPE.Moniter: Client c5 = new ClientMoniter(v, ConfigPath); Clients.Add(App, c5); break; default: break; } break; } } } } } return(Clients[App]); }
public static Client CreateClient(APPID App, string ConfigPath) { if (!Clients.ContainsKey(App)) { lock (SynObject) { if (!Clients.ContainsKey(App)) { foreach (var v in Apps) { if (v.id == App) { switch (v.type) { case APPTYPE.App2Res: Client c1 = new ClientApp(v, ConfigPath); Clients.Add(App, c1); break; case APPTYPE.App2App: Client c2 = new ClientP2P(v, ConfigPath); Clients.Add(App, c2); break; case APPTYPE.Res2App: Client c3 = new ClientRes(v, ConfigPath); Clients.Add(App, c3); break; case APPTYPE.Authorization: Client c4 = new ClientAuthor(v, ConfigPath); Clients.Add(App, c4); break; case APPTYPE.Moniter: Client c5 = new ClientMoniter(v, ConfigPath); Clients.Add(App, c5); break; default: break; } break; } } } } } return Clients[App]; }