Click here to Skip to main content
12,405,270 members (61,530 online)
Click here to Skip to main content
Articles » Languages » C# » General » Downloads

Stats

172.8K views
9.6K downloads
65 bookmarked
Posted

STUN Client

, 20 Apr 2007 CPOL
STUN client C# implementation with sample application
Stun
Net
docs
dns
dns_records.jpg
dns_records.vsd
Net
_junk
_Obsolete
_Stuff
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
SDP
ServersCore
SIP
Client
Message
Proxy
Stack
SMTP
Client
Server
STUN
Client
Message
STUN_Client_app
STUN_Client_app.suo
STUN_Client_app
bin
Debug
LumiSoft.Net.dll
STUN_Client_app.exe
STUN_Client_app.vshost.exe
dep
LumiSoft.Net.dll
Properties
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

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 20 Apr 2007
Article Copyright 2007 by Ivar Lumi
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid