SIPSorcery.SIP.App.SIPMonitorMachineEvent.ToAnonymousCSV C# (CSharp) Method

ToAnonymousCSV() public method

public ToAnonymousCSV ( ) : string
return string
        public string ToAnonymousCSV()
        {
            try
            {
                int machineEventTypeId = (int)MachineEventType;
                string remoteSocket = null;

                if (RemoteEndPoint != null)
                {
                    // This is the equivalent of applying a /20 mask to the IP address to obscure the bottom 12 bits of the address.
                    byte[] addressBytes = RemoteEndPoint.Address.GetAddressBytes();
                    addressBytes[3] = 0;
                    addressBytes[2] = (byte)(addressBytes[2] & 0xf0);
                    IPAddress anonymisedIPAddress = new IPAddress(addressBytes);
                    remoteSocket = (RemoteEndPoint != null) ? anonymisedIPAddress.ToString() + ":" + RemoteEndPoint.Port : null;
                }

                string csvEvent =
                    SERIALISATION_PREFIX + "|" +
                    SessionID + "|" +
                    MonitorServerID + "|" +
                    machineEventTypeId + "|" +
                    Created.ToString(SERIALISATION_DATETIME_FORMAT) + "|" +
                    "|" +
                    remoteSocket + "|" +
                    "|" +
                    "|" +
                    END_MESSAGE_DELIMITER;

                return csvEvent;
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPMonitorMachineEvent ToAnonymousCSV. " + excp.Message);
                return null;
            }
        }