internal static void Dispatch(Manager manager, Session session, Protocol protocol) { //Task task = new Task(manager, session, protocol); //ThreadPool.AddTask(task); //CUI Modify in 2014/05/26 manager.OnRecvProtocol(session, protocol); }
private Task(Manager _manager, Session _session, Protocol _protocol) : base() { manager = _manager; session = _session; protocol = _protocol; time_start = WatchDog.GetTime(); }
public static ActiveIO Open(NetSession assoc_session, Manager manager) { Console.WriteLine("ActiveIO::Open"); if (assoc_session == null || manager == null) return null; Socket ssc = null; try { ssc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); ssc.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); ssc.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, SO_SENDBUF); ssc.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, SO_RECVBUF); // 首先使用地址 IPAddress address; if (IPAddress.TryParse(manager.HostName, out address)) { IPEndPoint sa = new IPEndPoint(address, manager.Port); return new ActiveIO(ssc, sa, assoc_session); } else { return new ActiveIO(ssc, assoc_session, manager.HostName, manager.Port); } } catch (Exception e) { UnityEngine.Debug.LogWarning(e); Console.WriteLine(e.StackTrace); Console.WriteLine(e.Message); if (ssc != null) ssc.Close(); } return null; }
public ReconnectTask(Manager m, int priority) : base() { manager = m; }
public virtual void Process(Manager manager, Session session) { manager.OnRecvProtocol(session, this); }
public static Session Client(Manager manager) { Session session = new Session(manager); ActiveIO.Open(session, manager); return session; }
public static PassiveIO Server(Manager manager) { return PassiveIO.Open(new Session(manager)); }
public Session(Manager m) { manager = m; // state = manager.GetInitState(); timer = new WatchDog(); m_sessionID = ++session_id; }