Ejemplo n.º 1
0
 public static void GenSocketLog(MsgPackSession session, string cmdtype, byte[] data, bool isreq = true)
 {
     try
     {
         if (logCmd)
         {
             var log = new Data.socketlog();
             log.id       = DateTime.Now.Ticks.ToString();
             log.datetime = DateTime.Now;
             var clientip = string.Empty;
             if (session != null && session.RemoteEndPoint != null)
             {
                 clientip = session.RemoteEndPoint.Address.ToString() + ":" + session.RemoteEndPoint.Port;
             }
             log.clientip = clientip;
             log.cmdtype  = cmdtype;
             log.senddata = ToHexString(data);
             log.isreq    = isreq;
             ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => {
                 Data.expressEntities db = new Data.expressEntities();
                 db.socketlogs.Add((Data.socketlog)obj);
                 db.SaveChanges();
             }), log);
         }
     }
     catch (Exception es)
     {
         LogHelper.LogError(es);
     }
 }
Ejemplo n.º 2
0
 public static void SendData(MsgPackSession session, byte[] data)
 {
     if (logSendData)
     {
         var sendInfo = "SEND: " + BitConverter.ToString(data);
         Console.WriteLine(sendInfo);
         LogHelper.LogInfo(sendInfo);
     }
     session.Send(data, 0, data.Length);
 }
Ejemplo n.º 3
0
 static void appServer_NewSessionConnected(MsgPackSession session)
 {
     if (AsServer)
     {
         LogHelper.LogInfo(string.Format("Session [{0}] Connect!", session.SessionID));
     }
     else
     {
         Console.WriteLine(string.Format("Session[{0}] Connect!", session.SessionID));
     }
 }
Ejemplo n.º 4
0
 static void AppServer_SessionClosed(MsgPackSession session, CloseReason value)
 {
     if (AsServer)
     {
         LogHelper.LogInfo(string.Format("Session [{0}] Closed!", session.SessionID));
     }
     else
     {
         Console.WriteLine(string.Format("Session[{0}] Closed!", session.SessionID));
     }
 }