Ejemplo n.º 1
0
Archivo: Task.cs Proyecto: fengqk/Art
        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);
        }
Ejemplo n.º 2
0
Archivo: Task.cs Proyecto: fengqk/Art
 private Task(Manager _manager, Session _session, Protocol _protocol)
     : base()
 {
     manager = _manager;
     session = _session;
     protocol = _protocol;
     time_start = WatchDog.GetTime();
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public ReconnectTask(Manager m, int priority)
     : base()
 {
     manager = m;
 }
Ejemplo n.º 5
0
 public virtual void Process(Manager manager, Session session)
 {
     manager.OnRecvProtocol(session, this);
 }
Ejemplo n.º 6
0
 public static Session Client(Manager manager)
 {
     Session session = new Session(manager);
     ActiveIO.Open(session, manager);
     return session;
 }
Ejemplo n.º 7
0
 public static PassiveIO Server(Manager manager)
 {
     return PassiveIO.Open(new Session(manager));
 }
Ejemplo n.º 8
0
	    public Session(Manager m)
	    {
		    manager = m;
		    // state = manager.GetInitState();
            timer = new WatchDog();
            m_sessionID = ++session_id;
        }