Exemplo n.º 1
0
Arquivo: Task.cs Projeto: 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);
        }
Exemplo n.º 2
0
 protected internal override void OnAbortSession(Session session)
 {
     if (this.session != null)
         Console.WriteLine("PingClient::OnAbortSession " + this.session.getPeerAddress().ToString());
     this.session = null;
     //reconnect
 }
Exemplo n.º 3
0
Arquivo: Task.cs Projeto: fengqk/Art
 private Task(Manager _manager, Session _session, Protocol _protocol)
     : base()
 {
     manager = _manager;
     session = _session;
     protocol = _protocol;
     time_start = WatchDog.GetTime();
 }
Exemplo n.º 4
0
        protected internal override void OnAddSession(Session session)
        {
            Console.WriteLine("PingClient::OnAddSession");
            this.session = session;
            lock (locker)
            {
                pingmap[session.ID] = Environment.TickCount;
            }

        }
Exemplo n.º 5
0
 internal void AbortSession(Session session)
 {
     try
     {
         OnAbortSession(session);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         Console.WriteLine(e.StackTrace);
     }
 }
Exemplo n.º 6
0
        public override void OnRecvProtocol(Session session, Protocol protocol)
        {
			//UnityEngine.Debug.Log("DirClient:OnRecvProtocol. procotol type:" + protocol.getProtocolType().ToString());
            if(protocol.getProtocolType()==DirInfo.PROTOCOL_TYPE)
		    {
                DirInfo p = protocol as DirInfo;
                if(p!=null)
                {
			        Close(session);
					m_dirInfo = p;
					m_requesting = false;
                }
		    }
        }
Exemplo n.º 7
0
        protected internal override void OnAddSession(Session session)
        {

            lock (locker)
            {
                if (m_callback == null)
                    return;
                if (m_state != (int)STATE.STATE_CONNECTING)
                    return;
                this.session = session;
                if (m_callback != null && m_state == (int)STATE.STATE_CONNECTING && this.session == session)
                    m_callback(null, session, (int)EVENT.EVENT_ADDSESSION);

                Console.WriteLine("GameClient::OnAddSession");
            }
        }
Exemplo n.º 8
0
        internal void DelSession(Session session)
        {
            try
            {
                OnDelSession(session);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

            lock (ilock)
            {
                set.Remove(session);
            }
        }
Exemplo n.º 9
0
 internal void AddSession(Session session)
 {
     lock (ilock)
     {
         set.Add(session);
     }
     
     try
     {
         OnAddSession(session);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         Console.WriteLine(e.StackTrace);
     }
 }
Exemplo n.º 10
0
	    public override Object Clone()
	    {
		    try
		    {
			    Session s = new Session(ibuffer.capacity(), obuffer.capacity(), isecbuf.capacity(), isec, osec);
			    // s.state = new State(state);
			    s.ism = new Stream(s);
			    s.os = new LinkedList<OctetsStream>();                
                s.timer = new WatchDog();
                s.manager = manager;
			    return s;
		    }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
		    return null;
	    }
Exemplo n.º 11
0
Arquivo: Stream.cs Projeto: fengqk/Art
 internal Stream(Session s, int size) : base(size) { session = s; }
Exemplo n.º 12
0
		public static void AbortRequest(Session session)
		{
			GetInstance().Close(session);
		}
Exemplo n.º 13
0
Arquivo: Stream.cs Projeto: fengqk/Art
 internal Stream(Session s) { session = s; }
Exemplo n.º 14
0
        protected internal override void OnAbortSession(Session session)
        {
			//if (this.session != null)
			//    UnityEngine.Debug.Log("DirClient::OnAbortSession " + this.session.getPeerAddress().ToString());
            this.session = null;
        }
Exemplo n.º 15
0
        protected internal override void OnAbortSession(Session session)
        {
            lock (locker)
            {
				if(this.session != session) return;

                if (m_callback != null && m_state == (int)STATE.STATE_CONNECTING /*&& this.session == session*/)
                    m_callback(null, session, (int)EVENT.EVENT_ABORTSESSION);

                this.session = null;

            }
        }
Exemplo n.º 16
0
        public override void OnRecvProtocol(Session session, Protocol protocol)
        {
            Console.WriteLine("PingClient:OnRecvProtocol. procotol type:" + protocol.getProtocolType().ToString());
            if(protocol.getProtocolType()==Challenge.PROTOCOL_TYPE)
		    {
                Challenge p = protocol as Challenge;
                if(p!=null)
                {
                    ServerStatus status = new ServerStatus();
			       // status.attr = *(Attr*)(p->nonce.begin());
                    {
                        lock (locker) 
                        {
                            status.ping = (uint)(Environment.TickCount - pingmap[session.ID]);
                        }
                    }
			        if(status.ping<=5)
				            status.ping = 5;
			        status.ping = status.ping>9999?9999:status.ping;
                    m_callback(status, session, (int)EVENT.EVENT_PINGRETURN);
			        Close(session);
			        //p.Destroy();

                }
			   
		    }
        }
Exemplo n.º 17
0
        protected internal override void OnAddSession(Session session)
        {
			//UnityEngine.Debug.Log("DirClient::OnAddSession");
            this.session = session;
        }
Exemplo n.º 18
0
 public bool Send(Session session, Protocol protocol)
 {
     if (!set.Contains(session)) return false;
     return session.Send(protocol);
 }
Exemplo n.º 19
0
 public bool Close(Session session)
 {
     if (!set.Contains(session)) return false;
     session.Close();
     return true;
 }
Exemplo n.º 20
0
 public static Session Client(Manager manager)
 {
     Session session = new Session(manager);
     ActiveIO.Open(session, manager);
     return session;
 }
Exemplo n.º 21
0
 protected internal virtual void OnAbortSession(Session session) { }
Exemplo n.º 22
0
 protected internal override void OnAddSession(Session session)
 {
     this.session = session;
 }
Exemplo n.º 23
0
        public override void OnRecvProtocol(Session session, Protocol protocol)
        {
			try
			{
				lock (locker)
				{
					if (this.session == session)
					{
						if (protocol.getProtocolType() == KeepAlive.PROTOCOL_TYPE)
						{
							m_lastrecv = (uint)Environment.TickCount;
							m_ping = m_lastrecv - m_lastsend;
							//protocol.Destroy();
						}
						else if (protocol.getProtocolType() == (int)GNET.NetProtocolType.PROTOCOL_MARSHALDATA)
						{
							CommonData p = (CommonData)protocol;
							GNET.MarshalData md = new GNET.MarshalData();

							md.unmarshal(p.GetData());

							Protocol prtc = Protocol.DecodeMarshal(md.data);
							protocol = null;
							if (prtc != null)
								m_callback(prtc, session, (int)WM.WM_IOPROTOCOL);
						}
						else
						{
							m_callback(protocol, session, (int)WM.WM_IOPROTOCOL);
						}
					}
				}
			}
			catch (Exception e)
			{
				Debug.LogException(e);	//线程里,输出下错误信息
			}
        }
Exemplo n.º 24
0
        protected internal override void OnDelSession(Session session)
        {
            lock (locker)
            {
                if (this.session != session) return;

                if (m_callback != null)
                {
                    if (m_state == (int)STATE.STATE_KEEPING)
                    {
                        m_state = (int)STATE.STATE_CLOSED;
                    }
                    m_callback(null, session, (int)EVENT.EVENT_DISCONNECT);
                }

                this.session = null;
            }
        }
Exemplo n.º 25
0
 public virtual void Process(Manager manager, Session session)
 {
     manager.OnRecvProtocol(session, this);
 }
Exemplo n.º 26
0
 public bool ChangeState(Session session, String name)
 {
     if (!set.Contains(session)) return false;
     session.ChangeState(name);
     return true;
 }
Exemplo n.º 27
0
 internal bool SetOSecurity(Session session, String type, Octets key)
 {
     if (!set.Contains(session)) return false;
     session.SetOSecurity(type, key);
     return true;
 }
Exemplo n.º 28
0
 public virtual void OnRecvProtocol(Session session, Protocol protocol) {}
Exemplo n.º 29
0
    protected internal override void OnDelSession(Session session)
    {
       this.session = null;
 
    }
Exemplo n.º 30
0
 protected internal abstract void OnDelSession(Session session);