public void TestSockSessClient() { SockSessClient client = new SockSessClient(); client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 3002)); client.recv_event += new SockSessDelegate(RecvEvent); client.wfifo.Append(Encoding.UTF8.GetBytes("Hello SockSessClient")); }
public Core() { RegisterService("notice.sesslisten", SessListenNotice, OnServiceDone); RegisterService("notice.sessaccept", SessAcceptNotice, OnServiceDone); RegisterService("notice.sessclose", SessCloseNotice, OnServiceDone); RegisterService("service.sessdetail", SessDetailResponse, OnServiceDone); RegisterService("service.sessgroupstate", SessGroupStateResponse, OnServiceDone); RegisterService("notice.moduleadd", ModuleAddNotice, OnServiceDone); RegisterService("notice.moduledelete", ModuleDeleteNotice, OnServiceDone); RegisterService("notice.moduleupdate", ModuleUpdateNotice, OnServiceDone); RegisterService("service.moduledetail", ModuleDetailResponse, OnServiceDone); try { envclient = new SockSessClient(); envclient.recv_event += new SockSess.SockSessDelegate(OnRecvEvent); envclient.Connect(new IPEndPoint(IPAddress.Parse(serverip), serverport)); Loop.default_loop.Add(envclient); } catch (Exception ex) { System.Windows.MessageBox.Show("failed to connect to server." + Environment.NewLine + ex.ToString()); System.Threading.Thread.CurrentThread.Abort(); } uidata = new UIData(); System.Timers.Timer timer = new System.Timers.Timer(30 * 1000); timer.Elapsed += new System.Timers.ElapsedEventHandler((s, ea) => { SessDetailRequest(); SessGroupStateRequest(); }); timer.Start(); }
protected SockSessClient MakeConnect(IPEndPoint ep) { SockSessClient client = new SockSessClient(); client.Connect(ep); client.close_event += new SockSessDelegate(CloseEvent); client.recv_event += new SockSessDelegate(RecvEvent); sess_group.Add(client); return client; }
public SockSessClient MakeConnect(IPEndPoint ep) { SockSessClient client = new SockSessClient(); client.Connect(ep); client.close_event += new SockSess.SockSessDelegate(OnCloseEvent); client.recv_event += new SockSess.SockSessDelegate(OnRecvEvent); if (sess_connect_event != null) { sess_connect_event(this, client); } Loop.default_loop.Add(client); sesstab.Add(client); sessstate.ConnectCount++; return(client); }