Connections Property

Summary

Retrieves the number of active connections the client currently has.

Syntax
C#
VB
C++
public int Connections { get; } 
Public ReadOnly Property Connections As Integer 
public: 
property int Connections { 
   int get(); 
} 

Property Value

An integer value representing the number of active connections.

Remarks

A client will be deleted if it has not had any active connections for 60 seconds.

If the method fails, an error is raised. For more information, refer to the Error Codes.

Example
C#
VB
using Leadtools; 
using Leadtools.MediaStreaming; 
 
 
public Server _server = null; 
public bool _result = false; 
 
public void PrintClientsExample() 
{ 
   try 
   { 
      int Count = 0; 
      string strClients = ""; 
 
      // create an instance of the server object 
      _server = new Leadtools.MediaStreaming.Server(); 
 
 
      // edit network properties, application properties, MIME types, or IP filters here 
 
      // start the server 
      _server.Start(); 
 
      // make sure that there is some clients connected to the server. 
 
      // retrieve a copy of the Application Properties 
      Clients clients = _server.GetClients(); 
 
      //Get the Application Properties count 
      Count = clients.Count; 
 
      // print the clients items to a string 
 
      strClients += string.Format("--- Clients (count = {0}) ---\n\n", Count.ToString()); 
 
      int nIndex = 0; 
      foreach (Client client in clients) 
      { 
         string ip; 
         int connections; 
         double connectiontime; 
 
         // get IP Address 
         ip = client.IPAddress; 
 
         // get number of connections 
         connections = client.Connections; 
 
         // get connection time 
         connectiontime = client.ConnectionTime; 
 
         // convert to local time 
         DateTime dt = DateTime.FromOADate(connectiontime); 
         DateTime dtLocal = dt.ToLocalTime(); 
         string sconnectiontime = dtLocal.ToString("yyyy-MM-dd HH:mm:ss"); 
 
         strClients += string.Format("Client[{0}]: {1}, connections = {2}, connection time = {3}\n", nIndex.ToString(), ip, connections.ToString(), sconnectiontime); 
 
         nIndex++; 
      } 
 
      // display a message contains the clients information string 
      MessageBox.Show(strClients, "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information); 
 
      _result = true; 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
Imports Leadtools 
Imports Leadtools.MediaStreaming 
 
 
Public _server As Server = Nothing 
Public _result As Boolean = False 
 
Public Sub PrintClientsExample() 
   Try 
      Dim Count As Integer = 0 
      Dim strClients As String = "" 
 
      ' create an instance of the server object 
      _server = New Leadtools.MediaStreaming.Server() 
 
 
      ' edit network properties, application properties, MIME types, or IP filters here 
 
      ' start the server 
      _server.Start() 
 
      ' make sure that there is some clients connected to the server. 
 
      ' retrieve a copy of the Application Properties 
      Dim clients As Clients = _server.GetClients() 
 
      'Get the Application Properties count 
      Count = clients.Count 
 
      ' print the clients items to a string 
 
      strClients &= String.Format("--- Clients (count = {0}) ---" & Constants.vbLf + Constants.vbLf, Count.ToString()) 
 
      Dim nIndex As Integer = 0 
      For Each client As Client In clients 
         Dim ip As String 
         Dim connections As Integer 
         Dim connectiontime As Double 
 
         ' get IP Address 
         ip = client.IPAddress 
 
         ' get number of connections 
         connections = client.Connections 
 
         ' get connection time 
         connectiontime = client.ConnectionTime 
 
         ' convert to local time 
         Dim dt As DateTime = DateTime.FromOADate(connectiontime) 
         Dim dtLocal As DateTime = dt.ToLocalTime() 
         Dim sconnectiontime As String = dtLocal.ToString("yyyy-MM-dd HH:mm:ss") 
 
         strClients &= String.Format("Client[{0}]: {1}, connections = {2}, connection time = {3}" & Constants.vbLf, nIndex.ToString(), ip, connections.ToString(), sconnectiontime) 
 
         nIndex += 1 
      Next client 
 
      ' display a message contains the clients information string 
      MessageBox.Show(strClients, "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information) 
 
      _result = True 
   Catch e1 As Exception 
      _result = False 
   End Try 
End Sub 

Requirements

Target Platforms

See Also

Reference

Client Class

Client Members

Help Version 20.0.2020.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MediaStreaming Assembly