C#
VB
C++
Retrieves the IP address of the client that made the request.
string ClientIP {get;}
ReadOnly Property ClientIP As String
property String^ ClientIP {
String^ get();
}
A string that represents the IP address of the client that made the request.
If the method fails, an error is raised. For more information, refer to the Error Codes.
using Leadtools;
using Leadtools.MediaStreaming;
enum W3CLOG
{
date = 0x00000001,
time = 0x00000002,
c_ip = 0x00000004,
cs_username = 0x00000008,
s_sitename = 0x00000010,
s_computername = 0x00000020,
s_ip = 0x00000040,
s_port = 0x00000080,
cs_method = 0x00000100,
cs_uri_stem = 0x00000200,
cs_uri_query = 0x00000400,
sc_status = 0x00000800,
sc_win32_status = 0x00001000,
sc_bytes = 0x00002000,
cs_bytes = 0x00004000,
time_taken = 0x00008000,
cs_version = 0x00010000,
cs_host = 0x00020000,
cs_user_agent = 0x00040000,
cs_cookie = 0x00080000,
cs_referer = 0x00100000,
sc_substatus = 0x00200000,
};
public class CW3CLogHandler : ILtmsLogHandler
{
bool m_enable;
int m_fields;
bool m_localtime;
DateTime m_dtfile;
string m_software;
string m_folder;
string m_prefix;
StreamWriter m_sw;
public CW3CLogHandler(string prefix, string software, bool enable, string folder, int fields, bool localtime)
{
m_prefix = prefix;
m_software = software;
m_enable = enable;
m_folder = folder;
m_fields = fields;
m_localtime = localtime;
}
~CW3CLogHandler()
{
}
void WriteString(string str)
{
m_sw.Write(str);
}
DateTime GetTime(double dTime)
{
DateTime dt = DateTime.FromOADate(dTime);
if (m_localtime)
return dt.ToLocalTime();
return dt;
}
string GetLogPath(double timestamp)
{
DateTime dt = GetTime(timestamp);
string strFullPath;
try
{
PathResolver resolver = new PathResolver();
strFullPath = resolver.Resolve(m_folder);
}
catch
{
return "";
}
strFullPath += "\\";
strFullPath += m_prefix;
if (!m_localtime)
{
strFullPath += dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") + "UTC.log";
}
else
{
strFullPath += dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") + ".log";
}
return strFullPath;
}
public void LoadConfig(Server server)
{
bool enable = m_enable;
bool localtime = m_localtime;
string folder = m_folder;
int fields = m_fields;
bool dirty = false;
ApplicationProperties AppProps = server.GetApplicationProperties();
try
{
enable = AppProps.GetBoolean("LogEnable");
}
catch
{
AppProps.AddBoolean("LogEnable", enable);
dirty = true;
}
try
{
localtime = AppProps.GetBoolean("LogLocalTime");
}
catch
{
AppProps.AddBoolean("LogLocalTime", localtime);
dirty = true;
}
try
{
folder = AppProps.GetString("LogFolder");
}
catch
{
AppProps.AddString("LogFolder", folder);
dirty = true;
}
try
{
fields = AppProps.GetInteger("LogFields");
}
catch
{
AppProps.AddInteger("LogFields", fields);
dirty = true;
}
if (dirty)
server.SetApplicationProperties(AppProps);
// if anything has changed then we need to close the current file
if (!enable && (string.Compare(m_folder, folder, true) != 0) || fields != m_fields || m_localtime != localtime)
{
if (m_sw != null)
m_sw.Close();
}
m_folder = folder;
m_localtime = localtime;
m_enable = enable;
m_fields = fields;
}
bool CreateLog(double timestamp)
{
if (m_sw != null)
m_sw.Close();
if (!m_enable)
return false;
try
{
m_sw = File.CreateText(GetLogPath(timestamp));
}
catch
{
return false;
}
m_dtfile = GetTime(timestamp);
string s;
s = "#Software: " + m_software + "\r\n";
WriteString(s);
WriteString("#Version: 1.0\r\n");
DateTime dt = GetTime(timestamp);
s = "#Date: " + dt.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n";
WriteString(s);
s = "#Fields:";
if ((m_fields & (int)W3CLOG.date) == (int)W3CLOG.date)
{
s += " date";
}
if ((m_fields & (int)W3CLOG.time) == (int)W3CLOG.time)
{
s += " time";
}
if ((m_fields & (int)W3CLOG.s_sitename) == (int)W3CLOG.s_sitename)
{
s += " s-sitename";
}
if ((m_fields & (int)W3CLOG.s_computername) == (int)W3CLOG.s_computername)
{
s += " s-computername";
}
if ((m_fields & (int)W3CLOG.s_ip) == (int)W3CLOG.s_ip)
{
s += " s-ip";
}
if ((m_fields & (int)W3CLOG.cs_method) == (int)W3CLOG.cs_method)
{
s += " cs-method";
}
if ((m_fields & (int)W3CLOG.cs_uri_stem) == (int)W3CLOG.cs_uri_stem)
{
s += " cs-uri-stem";
}
if ((m_fields & (int)W3CLOG.cs_uri_query) == (int)W3CLOG.cs_uri_query)
{
s += " cs-uri-query";
}
if ((m_fields & (int)W3CLOG.s_port) == (int)W3CLOG.s_port)
{
s += " s-port";
}
if ((m_fields & (int)W3CLOG.cs_username) == (int)W3CLOG.cs_username)
{
s += " cs-username";
}
if ((m_fields & (int)W3CLOG.c_ip) == (int)W3CLOG.c_ip)
{
s += " c-ip";
}
if ((m_fields & (int)W3CLOG.cs_version) == (int)W3CLOG.cs_version)
{
s += " cs-version";
}
if ((m_fields & (int)W3CLOG.cs_user_agent) == (int)W3CLOG.cs_user_agent)
{
s += " cs(User-Agent)";
}
if ((m_fields & (int)W3CLOG.cs_cookie) == (int)W3CLOG.cs_cookie)
{
s += " cs(Cookie)";
}
if ((m_fields & (int)W3CLOG.cs_referer) == (int)W3CLOG.cs_referer)
{
s += " cs(Referer)";
}
if ((m_fields & (int)W3CLOG.cs_host) == (int)W3CLOG.cs_host)
{
s += " cs-host";
}
if ((m_fields & (int)W3CLOG.sc_status) == (int)W3CLOG.sc_status)
{
s += " sc-status";
}
if ((m_fields & (int)W3CLOG.sc_substatus) == (int)W3CLOG.sc_substatus)
{
s += " sc-substatus";
}
if ((m_fields & (int)W3CLOG.sc_win32_status) == (int)W3CLOG.sc_win32_status)
{
s += " sc-win32-status";
}
if ((m_fields & (int)W3CLOG.sc_bytes) == (int)W3CLOG.sc_bytes)
{
s += " sc-bytes";
}
if ((m_fields & (int)W3CLOG.cs_bytes) == (int)W3CLOG.cs_bytes)
{
s += " cs-bytes";
}
if ((m_fields & (int)W3CLOG.time_taken) == (int)W3CLOG.time_taken)
{
s += " time-taken";
}
s += "\r\n";
WriteString(s);
m_sw.Flush();
return true;
}
string escape(string s)
{
string t = "";
foreach (char c in s)
{
if (!char.IsControl(c) && !char.IsWhiteSpace(c))
t += c;
else
t += "+";
}
return t;
}
public void InitializeLog(double timestamp)
{
CreateLog(timestamp);
}
public void TerminateLog()
{
if (m_sw != null)
m_sw.Close();
}
public void LogInformation(ILtmsLogInformation info)
{
string s = "";
if (!m_enable)
return;
// check if we need to roll to a new file
{
DateTime dt = GetTime(info.TimeStamp);
if (m_sw == null || dt.Day != m_dtfile.Day || dt.Month != m_dtfile.Month || dt.Year != m_dtfile.Year)
{
if (!CreateLog(info.TimeStamp))
return;
}
}
if ((m_fields & (int)W3CLOG.date) == (int)W3CLOG.date)
{
DateTime dt = GetTime(info.TimeStamp);
if (s.Length > 0)
s += " ";
s += dt.ToString("yyyy-MM-dd");
}
if ((m_fields & (int)W3CLOG.time) == (int)W3CLOG.time)
{
DateTime dt = GetTime(info.TimeStamp);
if (s.Length > 0)
s += " ";
s += dt.ToString("HH:mm:ss");
}
if ((m_fields & (int)W3CLOG.s_sitename) == (int)W3CLOG.s_sitename)
{
string str = info.SiteName;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.s_computername) == (int)W3CLOG.s_computername)
{
string str = info.ComputerName;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.s_ip) == (int)W3CLOG.s_ip)
{
string str = info.ServerIP;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_method) == (int)W3CLOG.cs_method)
{
string str = info.Method;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_uri_stem) == (int)W3CLOG.cs_uri_stem)
{
string str = info.URIStem;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_uri_query) == (int)W3CLOG.cs_uri_query)
{
string str = info.URIQuery;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.s_port) == (int)W3CLOG.s_port)
{
int n = info.ServerPort;
if (s.Length > 0)
s += " ";
s += n.ToString();
}
if ((m_fields & (int)W3CLOG.cs_username) == (int)W3CLOG.cs_username)
{
string str = info.UserName;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.c_ip) == (int)W3CLOG.c_ip)
{
string str = info.ClientIP;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_version) == (int)W3CLOG.cs_version)
{
string str = info.ProtocolVersion;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_user_agent) == (int)W3CLOG.cs_user_agent)
{
string str = info.UserAgent;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_cookie) == (int)W3CLOG.cs_cookie)
{
string str = info.Cookie;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_referer) == (int)W3CLOG.cs_referer)
{
string str = info.Referrer;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.cs_host) == (int)W3CLOG.cs_host)
{
string str = info.Host;
if (s.Length > 0)
s += " ";
if (str.Length == 0)
s += "-";
else
s += escape(str);
}
if ((m_fields & (int)W3CLOG.sc_status) == (int)W3CLOG.sc_status)
{
int n = info.Status;
if (s.Length > 0)
s += " ";
s += n.ToString();
}
if ((m_fields & (int)W3CLOG.sc_substatus) == (int)W3CLOG.sc_substatus)
{
int n = info.ProtocolSubStatus;
if (s.Length > 0)
s += " ";
s += n.ToString();
}
if ((m_fields & (int)W3CLOG.sc_win32_status) == (int)W3CLOG.sc_win32_status)
{
int n = info.Win32Status;
if (s.Length > 0)
s += " ";
s += n.ToString();
}
if ((m_fields & (int)W3CLOG.sc_bytes) == (int)W3CLOG.sc_bytes)
{
int n = info.BytesSent;
if (s.Length > 0)
s += " ";
if (n < 0)
s += "-";
else
s += n.ToString();
}
if ((m_fields & (int)W3CLOG.cs_bytes) == (int)W3CLOG.cs_bytes)
{
int n = info.BytesReceived;
if (s.Length > 0)
s += " ";
if (n < 0)
s += "-";
else
s += n.ToString();
}
if ((m_fields & (int)W3CLOG.time_taken) == (int)W3CLOG.time_taken)
{
int n = info.TimeTaken;
if (s.Length > 0)
s += " ";
if (n < 0)
s += "-";
else
s += n.ToString();
}
s += "\r\n";
WriteString(s);
m_sw.Flush();
}
}
public Server _server = null;
public bool _result = false;
public void W3CLogHandlerExample()
{
try
{
State enumState;
CW3CLogHandler _loghandler;
// create an instance of the server object
_server = new Leadtools.MediaStreaming.Server();
// create the log handler
_loghandler = new CW3CLogHandler("ltmsServer_", "LEADTOOLS Media Streaming Server", true, "%ltmsLogFolder%", 0, false);
// set the log handler
_server.ILogHandler = _loghandler;
{
// for demonstration, compare the interface we just set
ILtmsLogHandler ihandler = null;
ihandler = _server.ILogHandler;
if (ihandler != (ILtmsLogHandler)_loghandler)
{
_result = false;
return;
}
}
// load the config file located in the config subfolder under the executable folder
// or comment this section out to run with the server�s default settings
_server.ImportConfigFile("%ltmsConfigFolder%\\LeadtoolsMediaStreamingServer.xml");
// start the server
_server.Start();
// confirm the running state for demonstration purposes
enumState = _server.State;
if (enumState == State.Started)
{
// display a message that the server is running and wait for OK
MessageBox.Show("The server has started. Press OK to stop.", "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
// stop the server
_server.Stop();
// remove the log handler
_server.ILogHandler = null;
_result = true;
}
catch (Exception)
{
_result = false;
}
}
Imports Leadtools
Imports Leadtools.MediaStreaming
Private Enum W3CLOG
[date] = &H1
time = &H2
c_ip = &H4
cs_username = &H8
s_sitename = &H10
s_computername = &H20
s_ip = &H40
s_port = &H80
cs_method = &H100
cs_uri_stem = &H200
cs_uri_query = &H400
sc_status = &H800
sc_win32_status = &H1000
sc_bytes = &H2000
cs_bytes = &H4000
time_taken = &H8000
cs_version = &H10000
cs_host = &H20000
cs_user_agent = &H40000
cs_cookie = &H80000
cs_referer = &H100000
sc_substatus = &H200000
End Enum
Public Class CW3CLogHandler : Implements ILtmsLogHandler
Private m_enable As Boolean
Private m_fields As Integer
Private m_localtime As Boolean
Private m_dtfile As DateTime
Private m_software As String
Private m_folder As String
Private m_prefix As String
Private m_sw As StreamWriter
Public Sub New(ByVal prefix As String, ByVal software As String, ByVal enable As Boolean, ByVal folder As String, ByVal fields As Integer, ByVal localtime As Boolean)
m_prefix = prefix
m_software = software
m_enable = enable
m_folder = folder
m_fields = fields
m_localtime = localtime
End Sub
Protected Overrides Sub Finalize()
End Sub
Private Sub WriteString(ByVal str As String)
m_sw.Write(str)
End Sub
Private Function GetTime(ByVal dTime As Double) As DateTime
Dim dt As DateTime = DateTime.FromOADate(dTime)
If m_localtime Then
Return dt.ToLocalTime()
End If
Return dt
End Function
Private Function GetLogPath(ByVal timestamp As Double) As String
Dim dt As DateTime = GetTime(timestamp)
Dim strFullPath As String
Try
Dim resolver As PathResolver = New PathResolver()
strFullPath = resolver.Resolve(m_folder)
Catch
Return ""
End Try
strFullPath &= "\"
strFullPath &= m_prefix
If (Not m_localtime) Then
strFullPath &= dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") & "UTC.log"
Else
strFullPath &= dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") & ".log"
End If
Return strFullPath
End Function
Public Sub LoadConfig(ByVal server As Server)
Dim enable As Boolean = m_enable
Dim localtime As Boolean = m_localtime
Dim folder As String = m_folder
Dim fields As Integer = m_fields
Dim dirty As Boolean = False
Dim AppProps As ApplicationProperties = server.GetApplicationProperties()
Try
enable = AppProps.GetBoolean("LogEnable")
Catch
AppProps.AddBoolean("LogEnable", enable)
dirty = True
End Try
Try
localtime = AppProps.GetBoolean("LogLocalTime")
Catch
AppProps.AddBoolean("LogLocalTime", localtime)
dirty = True
End Try
Try
folder = AppProps.GetString("LogFolder")
Catch
AppProps.AddString("LogFolder", folder)
dirty = True
End Try
Try
fields = AppProps.GetInteger("LogFields")
Catch
AppProps.AddInteger("LogFields", fields)
dirty = True
End Try
If dirty Then
server.SetApplicationProperties(AppProps)
End If
' if anything has changed then we need to close the current file
If (Not enable) AndAlso (String.Compare(m_folder, folder, True) <> 0) OrElse fields <> m_fields OrElse m_localtime <> localtime Then
If Not m_sw Is Nothing Then
m_sw.Close()
End If
End If
m_folder = folder
m_localtime = localtime
m_enable = enable
m_fields = fields
End Sub
Private Function CreateLog(ByVal timestamp As Double) As Boolean
If Not m_sw Is Nothing Then
m_sw.Close()
End If
If (Not m_enable) Then
Return False
End If
Try
m_sw = File.CreateText(GetLogPath(timestamp))
Catch
Return False
End Try
m_dtfile = GetTime(timestamp)
Dim s As String
s = "#Software: " & m_software & Constants.vbCrLf
WriteString(s)
WriteString("#Version: 1.0" & Constants.vbCrLf)
Dim dt As DateTime = GetTime(timestamp)
s = "#Date: " & dt.ToString("yyyy-MM-dd HH:mm:ss") & Constants.vbCrLf
WriteString(s)
s = "#Fields:"
If (m_fields And CInt(W3CLOG.date)) = CInt(W3CLOG.date) Then
s &= " date"
End If
If (m_fields And CInt(W3CLOG.time)) = CInt(W3CLOG.time) Then
s &= " time"
End If
If (m_fields And CInt(W3CLOG.s_sitename)) = CInt(W3CLOG.s_sitename) Then
s &= " s-sitename"
End If
If (m_fields And CInt(W3CLOG.s_computername)) = CInt(W3CLOG.s_computername) Then
s &= " s-computername"
End If
If (m_fields And CInt(W3CLOG.s_ip)) = CInt(W3CLOG.s_ip) Then
s &= " s-ip"
End If
If (m_fields And CInt(W3CLOG.cs_method)) = CInt(W3CLOG.cs_method) Then
s &= " cs-method"
End If
If (m_fields And CInt(W3CLOG.cs_uri_stem)) = CInt(W3CLOG.cs_uri_stem) Then
s &= " cs-uri-stem"
End If
If (m_fields And CInt(W3CLOG.cs_uri_query)) = CInt(W3CLOG.cs_uri_query) Then
s &= " cs-uri-query"
End If
If (m_fields And CInt(W3CLOG.s_port)) = CInt(W3CLOG.s_port) Then
s &= " s-port"
End If
If (m_fields And CInt(W3CLOG.cs_username)) = CInt(W3CLOG.cs_username) Then
s &= " cs-username"
End If
If (m_fields And CInt(W3CLOG.c_ip)) = CInt(W3CLOG.c_ip) Then
s &= " c-ip"
End If
If (m_fields And CInt(W3CLOG.cs_version)) = CInt(W3CLOG.cs_version) Then
s &= " cs-version"
End If
If (m_fields And CInt(W3CLOG.cs_user_agent)) = CInt(W3CLOG.cs_user_agent) Then
s &= " cs(User-Agent)"
End If
If (m_fields And CInt(W3CLOG.cs_cookie)) = CInt(W3CLOG.cs_cookie) Then
s &= " cs(Cookie)"
End If
If (m_fields And CInt(W3CLOG.cs_referer)) = CInt(W3CLOG.cs_referer) Then
s &= " cs(Referer)"
End If
If (m_fields And CInt(W3CLOG.cs_host)) = CInt(W3CLOG.cs_host) Then
s &= " cs-host"
End If
If (m_fields And CInt(W3CLOG.sc_status)) = CInt(W3CLOG.sc_status) Then
s &= " sc-status"
End If
If (m_fields And CInt(W3CLOG.sc_substatus)) = CInt(W3CLOG.sc_substatus) Then
s &= " sc-substatus"
End If
If (m_fields And CInt(W3CLOG.sc_win32_status)) = CInt(W3CLOG.sc_win32_status) Then
s &= " sc-win32-status"
End If
If (m_fields And CInt(W3CLOG.sc_bytes)) = CInt(W3CLOG.sc_bytes) Then
s &= " sc-bytes"
End If
If (m_fields And CInt(W3CLOG.cs_bytes)) = CInt(W3CLOG.cs_bytes) Then
s &= " cs-bytes"
End If
If (m_fields And CInt(W3CLOG.time_taken)) = CInt(W3CLOG.time_taken) Then
s &= " time-taken"
End If
s &= Constants.vbCrLf
WriteString(s)
m_sw.Flush()
Return True
End Function
Private Function escape(ByVal s As String) As String
Dim t As String = ""
For Each c As Char In s
If (Not Char.IsControl(c)) AndAlso (Not Char.IsWhiteSpace(c)) Then
t &= c
Else
t &= "+"
End If
Next c
Return t
End Function
Public Sub InitializeLog(ByVal timestamp As Double) Implements ILtmsLogHandler.InitializeLog
CreateLog(timestamp)
End Sub
Public Sub TerminateLog() Implements ILtmsLogHandler.TerminateLog
If Not m_sw Is Nothing Then
m_sw.Close()
End If
End Sub
Public Sub LogInformation(ByVal info As ILtmsLogInformation) Implements ILtmsLogHandler.LogInformation
Dim s As String = ""
If (Not m_enable) Then
Return
End If
' check if we need to roll to a new file
Dim dt As DateTime = GetTime(info.TimeStamp)
If m_sw Is Nothing OrElse dt.Day <> m_dtfile.Day OrElse dt.Month <> m_dtfile.Month OrElse dt.Year <> m_dtfile.Year Then
If (Not CreateLog(info.TimeStamp)) Then
Return
End If
End If
If (m_fields And CInt(W3CLOG.date)) = CInt(W3CLOG.date) Then
Dim dtDate As DateTime = GetTime(info.TimeStamp)
If s.Length > 0 Then
s &= " "
End If
s &= dtDate.ToString("yyyy-MM-dd")
End If
If (m_fields And CInt(W3CLOG.time)) = CInt(W3CLOG.time) Then
Dim dtTime As DateTime = GetTime(info.TimeStamp)
If s.Length > 0 Then
s &= " "
End If
s &= dtTime.ToString("HH:mm:ss")
End If
If (m_fields And CInt(W3CLOG.s_sitename)) = CInt(W3CLOG.s_sitename) Then
Dim str As String = info.SiteName
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.s_computername)) = CInt(W3CLOG.s_computername) Then
Dim str As String = info.ComputerName
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.s_ip)) = CInt(W3CLOG.s_ip) Then
Dim str As String = info.ServerIP
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_method)) = CInt(W3CLOG.cs_method) Then
Dim str As String = info.Method
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_uri_stem)) = CInt(W3CLOG.cs_uri_stem) Then
Dim str As String = info.URIStem
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_uri_query)) = CInt(W3CLOG.cs_uri_query) Then
Dim str As String = info.URIQuery
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.s_port)) = CInt(W3CLOG.s_port) Then
Dim n As Integer = info.ServerPort
If s.Length > 0 Then
s &= " "
End If
s &= n.ToString()
End If
If (m_fields And CInt(W3CLOG.cs_username)) = CInt(W3CLOG.cs_username) Then
Dim str As String = info.UserName
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.c_ip)) = CInt(W3CLOG.c_ip) Then
Dim str As String = info.ClientIP
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_version)) = CInt(W3CLOG.cs_version) Then
Dim str As String = info.ProtocolVersion
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_user_agent)) = CInt(W3CLOG.cs_user_agent) Then
Dim str As String = info.UserAgent
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_cookie)) = CInt(W3CLOG.cs_cookie) Then
Dim str As String = info.Cookie
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_referer)) = CInt(W3CLOG.cs_referer) Then
Dim str As String = info.Referrer
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.cs_host)) = CInt(W3CLOG.cs_host) Then
Dim str As String = info.Host
If s.Length > 0 Then
s &= " "
End If
If str.Length = 0 Then
s &= "-"
Else
s &= escape(str)
End If
End If
If (m_fields And CInt(W3CLOG.sc_status)) = CInt(W3CLOG.sc_status) Then
Dim n As Integer = info.Status
If s.Length > 0 Then
s &= " "
End If
s &= n.ToString()
End If
If (m_fields And CInt(W3CLOG.sc_substatus)) = CInt(W3CLOG.sc_substatus) Then
Dim n As Integer = info.ProtocolSubStatus
If s.Length > 0 Then
s &= " "
End If
s &= n.ToString()
End If
If (m_fields And CInt(W3CLOG.sc_win32_status)) = CInt(W3CLOG.sc_win32_status) Then
Dim n As Integer = info.Win32Status
If s.Length > 0 Then
s &= " "
End If
s &= n.ToString()
End If
If (m_fields And CInt(W3CLOG.sc_bytes)) = CInt(W3CLOG.sc_bytes) Then
Dim n As Integer = info.BytesSent
If s.Length > 0 Then
s &= " "
End If
If n < 0 Then
s &= "-"
Else
s &= n.ToString()
End If
End If
If (m_fields And CInt(W3CLOG.cs_bytes)) = CInt(W3CLOG.cs_bytes) Then
Dim n As Integer = info.BytesReceived
If s.Length > 0 Then
s &= " "
End If
If n < 0 Then
s &= "-"
Else
s &= n.ToString()
End If
End If
If (m_fields And CInt(W3CLOG.time_taken)) = CInt(W3CLOG.time_taken) Then
Dim n As Integer = info.TimeTaken
If s.Length > 0 Then
s &= " "
End If
If n < 0 Then
s &= "-"
Else
s &= n.ToString()
End If
End If
s &= Constants.vbCrLf
WriteString(s)
m_sw.Flush()
End Sub
End Class
Public _server As Server = Nothing
Public _result As Boolean = False
Public Sub W3CLogHandlerExample()
Try
Dim enumState As State
Dim _loghandler As CW3CLogHandler
' create an instance of the server object
_server = New Leadtools.MediaStreaming.Server()
' create the log handler
_loghandler = New CW3CLogHandler("ltmsServer_", "LEADTOOLS Media Streaming Server", True, "%ltmsLogFolder%", 0, False)
' set the log handler
_server.ILogHandler = _loghandler
' for demonstration, compare the interface we just set
Dim ihandler As ILtmsLogHandler = Nothing
ihandler = _server.ILogHandler
If Not ihandler Is CType(_loghandler, ILtmsLogHandler) Then
_result = False
Return
End If
' load the config file located in the config subfolder under the executable folder
' or comment this section out to run with the server�s default settings
_server.ImportConfigFile("%ltmsConfigFolder%\LeadtoolsMediaStreamingServer.xml")
' start the server
_server.Start()
' confirm the running state for demonstration purposes
enumState = _server.State
If enumState = State.Started Then
' display a message that the server is running and wait for OK
MessageBox.Show("The server has started. Press OK to stop.", "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
' stop the server
_server.Stop()
' remove the log handler
_server.ILogHandler = Nothing
_result = True
Catch e1 As Exception
_result = False
End Try
End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET