using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Protocol;
using System.Reflection;
using log4net;
using TZONE.Model;

namespace TZONE.GPSSocketServer
{
    public class GPSSession : AppSession<GPSSession, BinaryRequestInfo>
    {
        public new GPSServer AppServer
        {
            get
            {
                return (GPSServer)base.AppServer;
            }
        }

        ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        protected override void OnSessionClosed(CloseReason reason)
        {
#if DEBUG
            log.Info("------  " + IMEI);
            log.Debug("CLOSE ON_LINE_IMEI:-->" + GlobalVariables.GLOBAL_ON_LINE_IMEI.Count.ToString());
            foreach (string item in GlobalVariables.GLOBAL_ON_LINE_IMEI.Values)
            {
                log.Debug("CLOSE ON_LINE_IMEI:--> " + item);
            }
#endif
            if (!string.IsNullOrEmpty(IMEI))
            {
                try
                {

                    GlobalVariables.GLOBAL_ON_LINE_IMEI.Remove(IMEI);
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message);
                }
            }

            base.OnSessionClosed(reason);
        }

        /// <summary>
        /// 终端ID
        /// </summary>
        public string IMEI { get; set; }
        public int PID { get; set; }
        public int type_id { get; set; }
        public string product_model { get; set; }

    }
}
