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