コード例 #1
0
ファイル: CmdHelper.cs プロジェクト: chliam/express
 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);
     }
 }
コード例 #2
0
ファイル: CmdHelper.cs プロジェクト: chliam/express
 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);
 }
コード例 #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));
     }
 }
コード例 #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));
     }
 }