Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

SIP Stack with SIP Proxy - (VOIP)

, 11 Jun 2007 CPOL
C# implementation of SIP
SIP_Proxy_demo.zip
SIP_Proxy_demo
SIP_Proxy_demo.suo
SIP_Proxy_demo
bin
Debug
LumiSoft.Net.dll
SIP_Proxy_demo.exe
SIP_Proxy_demo.vshost.exe
dep
LumiSoft.Net.dll
LumiSoft.Net.pdb
Properties
Settings.settings
Resources
add.ico
app.ico
delete.ico
edit.ico
error.ico
info.ico
refresh.ico
rule.ico
server_running.ico
server_stopped.ico
viewmessages.ico
Stack.zip
Net
docs
dns
dns_records.jpg
dns_records.vsd
Net
_junk
_Obsolete
AUTH
bin
Release
LumiSoft.Net.dll
Data
Dns
Client
FTP
Client
Server
HTTP
Server
ICMP
IMAP
Client
Server
IO
Log
LumiSoft.Net
Mime
vCard
Net.csproj.user
Net.suo
NNTP
Client
POP3
Client
Server
RTP
SDP
ServersCore
SIP
Client
Message
Proxy
Stack
SMTP
Client
Server
STUN
Client
Message
URI
using System;
using System.Collections.Generic;
using System.Text;

namespace LumiSoft.Net.Log
{
    /// <summary>
    /// Represents method that will handle <b>WriteLog</b> event.
    /// </summary>
    /// <param name="entries">Log entries.</param>
    public delegate void WriteLogHandler(LogEntry[] entries);

    /// <summary>
    /// General logging module.
    /// </summary>
    public class Logger : IDisposable
    {   
        private List<LogEntry> m_pEntries = null;
 
        /// <summary>
        /// Default constructor.
        /// </summary>
        public Logger()
        {
            m_pEntries = new List<LogEntry>();
        }

        #region method Dispose

        /// <summary>
        /// Cleans up any resources being used.
        /// </summary>
        public void Dispose()
        {
            Flush();
        }

        #endregion


        #region method Flush

        /// <summary>
        /// Forces to write all buffered log entries.
        /// </summary>
        public void Flush()
        {
            lock(m_pEntries){
            }
        }

        #endregion


        #region method AddRead

        /// <summary>
        /// Adds read log entry.
        /// </summary>
        /// <param name="size">Readed data size in bytes.</param>
        /// <param name="text">Log text.</param>
        public void AddRead(int size,string text)
        {
            if(this.WriteLog != null){
                this.WriteLog(new LogEntry[]{new LogEntry(LogEntryType.Read,size,text)});
            }
        }

        #endregion

        #region method AddWrite

        /// <summary>
        /// Add write log entry.
        /// </summary>
        /// <param name="size">Written data size in bytes.</param>
        /// <param name="text">Log text.</param>
        public void AddWrite(int size,string text)
        {
            if(this.WriteLog != null){
                this.WriteLog(new LogEntry[]{new LogEntry(LogEntryType.Write,size,text)});
            }
        }

        #endregion

        #region method AddDebug

        /// <summary>
        /// Adds debug entry.
        /// </summary>
        /// <param name="text"></param>
        public void AddDebug(string text)
        {
            if(this.WriteLog != null){
                this.WriteLog(new LogEntry[]{new LogEntry(LogEntryType.Debug,0,text)});
            }
        }

        #endregion


        #region Properties Implementation

        #endregion
        
        #region Events Implementation

        /// <summary>
        /// Is raised when log buffer is full and log entries must be processed,
        /// </summary>
        public event WriteLogHandler WriteLog = null;

        #region method OnWriteLog

        /// <summary>
        /// Raises WriteLog event.
        /// </summary>
        private void OnWriteLog()
        {
            if(this.WriteLog != null){
                this.WriteLog(m_pEntries.ToArray());
            }
        }

        #endregion

        #endregion

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ivar Lumi

Estonia Estonia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150129.1 | Last Updated 11 Jun 2007
Article Copyright 2007 by Ivar Lumi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid