/// <summary> /// I received the data! /// </summary> protected override void ExecuteCommand(ClientSession session, BinaryRequestInfo requestInfo) { // Display the message in the UI. LocalMessageEventArgs e = new LocalMessageEventArgs((requestInfo.Body), TypeLocal.None); if (IsShowLog) { if (e.bMessage[3] != Constants.Hx01) { string time = DateTime.Now.ToString(Global.HHmmss); string ip = session.RemoteEndPoint.Address.ToString(); string sessionID = session.SessionID; string message = BitConverter.ToString(e.bMessage); //string log = string.Format("IP({0}_{1}_{2})_RESPONSE_{3}", session.RemoteEndPoint.Address.ToString(), session.SessionID, time, BitConverter.ToString(e.bMessage)); //string log = Global.FormatLog.Frmat(time, ip, sessionID, "RESPONSE " + message); //string.Format("[{0}] [{1}] [{2}] RESPONSE {3}", time, ip, sessionID, message); string log = $"[{time}]{Global.Separator}[{ip}]{Global.Separator}[{sessionID}]{Global.Separator}RESPONSE {message}"; OnShowLog(log); log = string.Format("({0})_RESPONSE_{1}", time, message); FileHelper.WriteLog("", log, string.Format(FolderName, ip), sessionID); } } OnReceived(session, e); }
private void session_OnMessaged(ClientSession session, LocalMessageEventArgs e) { if (IsShowLog) { string time = DateTime.Now.ToString(Global.HHmmss); string ip = session.RemoteEndPoint.Address.ToString(); string sessionID = session.SessionID; string message = BitConverter.ToString(e.bMessage); //string log = string.Format("IP({0}_{1}_{2})_OnMessaged_{3}", session.RemoteEndPoint.Address.ToString(), session.SessionID, time, e.Message); //string log = Global.FormatLog.Frmat(time, ip, sessionID, "OnMessaged " + message);//string.Format("[{0}] [{1}] [{2}] OnMessaged {3}", time, ip, sessionID, message); string log = $"[{time}]{Global.Separator}[{ip}]{Global.Separator}[{sessionID}]{Global.Separator}OnMessaged {message}"; OnShowLog(log); log = string.Format("({0})_OnMessaged_{1}", time, message); FileHelper.WriteLog("", log, string.Format(FolderName, ip), sessionID); } OnMessaged(session, e); }
/// <summary> /// Used to pass a message to the server object. /// </summary> private void SendMsg_ServerLog(string sMsg) { LocalMessageEventArgs e = new LocalMessageEventArgs(sMsg, TypeLocal.None); OnMessaged(this, e); }