Esempio n. 1
0
 /// <summary>
 /// 断线
 /// </summary>
 /// <param name="adapter"></param>
 protected virtual void OnDisconnect(NetAdapter adapter)
 {
 }
Esempio n. 2
0
        /// <summary>
        /// 添加适配器
        /// </summary>
        /// <param name="lAdapterID"></param>
        /// <param name="adapter"></param>
        protected void AddAdapter(long lAdapterID, NetAdapter adapter)
        {
            lock(mAdapterLock)
            {
                if (mAdapterDict.ContainsKey(lAdapterID))
                    return;

                mAdapterDict.Add(lAdapterID, adapter);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 当有连接连接上的时候
 /// </summary>
 /// <param name="param"></param>
 protected virtual void OnConnected(NetAdapter adapter)
 {
 }
Esempio n. 4
0
        /// <summary>
        /// 添加适配器
        /// </summary>
        /// <param name="net"></param>
        /// <param name="session"></param>
        /// <param name="adapter"></param>
        protected void AddAdapter(ENet net, object session, NetAdapter adapter)
        {
            lock(mAllAdapterLock)
            {
                Dictionary<object, NetAdapter> adapterDict;
                mAllAdapterDict.TryGetValue(net, out adapterDict);
                if (adapterDict == null)
                {
                    adapterDict = new Dictionary<object,NetAdapter>();
                    mAllAdapterDict.Add(net, adapterDict);
                }

                // 重复了
                if( adapterDict.ContainsKey(session) )
                {
                    return;
                }

                adapterDict.Add(session, adapter);
            }
        }