Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction | Help Version 19.0.2.15
|
Leadtools.MediaStreaming Namespace > Server Class : GetClients Method |
public Clients GetClients()
'Declaration
Public Function GetClients() As Clients
public: Clients^ GetClients();
If the method fails, an error is raised. For more information, refer to the Error Codes.
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
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; } }