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