[DispIdAttribute(2)]Connection NextConnection {get;}
An ILMNetSnk.Connection object that represents the next connection.
Use the LastConnection property to determine the last connection in the list of available connections to the server.
Use the ConnectionCount property to determine the number of live connections to the server.
Use the NextConnection property to get the next connection object from the list of available connections to the server.
Use the PrevConnection property to get the previous connection object from the list of available connections to the server.
Use the FindConnection method to get the object of the connection at the specified ID in the list of available connections to the server.
For more information, refer to the ILMNetSnk object.
using Leadtools;using Leadtools.Multimedia;using LeadtoolsMultimediaExamples.Fixtures;public bool _result = false;public CaptureAndPlayCtrlForm _serverAndClient = new CaptureAndPlayCtrlForm();CaptureCtrl _captureCtrl;PlayCtrl _playCtrl;LMNetMux _pMux;LMNetSnk _pSink;const string _networkUrl = @"ltsf://127.0.0.1:27015"; // network stream urlconst string _networkAuthenticatedUrl = @"ltsf://User1:[email protected]:27015"; // network stream urlconst string TestMessage = "LEAD NETWORK";public void RequireLoginExample(){// reference the capture control_captureCtrl = _serverAndClient.CaptureCtrl;// reference the play control_playCtrl = _serverAndClient.PlayCtrl;try{// try to find a video cameraif (_captureCtrl.VideoDevices["Logitech"] == null)throw new Exception("No Logitech video device available");_captureCtrl.VideoDevices["Logitech"].Selected = true;// select a video compressor_captureCtrl.VideoCompressors.Mpeg4.Selected = true;// set the target output file_captureCtrl.TargetFormat = TargetFormatType.NET;_captureCtrl.TargetFile = _networkUrl;if (_captureCtrl.IsModeAvailable(CaptureMode.Video)){// here we will only capture 15 seconds for this example.// in a real application, you would not normally want to// set the time limit for capture._captureCtrl.TimeLimit = 15;_captureCtrl.UseTimeLimit = true;// enable preview_captureCtrl.Preview = true;// subscribe to the started event for this example// we will connect a client after the capture starts_captureCtrl.Started += new EventHandler(CaptureCtrl_Started);// subcribe to the media event for the player_playCtrl.MediaEvent += new MediaEventHandler(PlayCtrl_MediaEvent);// ready the capture graph in order to get the LNMetMux instance_captureCtrl.ReadyCapture(CaptureMode.Video);// get the network multiplexer reference_pMux = _captureCtrl.GetSubObject(CaptureObject.TargetFilter) as LMNetMux;if (_pMux != null){// set some mux settings_pMux.LiveSource = true;}// get the network sink reference_pSink = _captureCtrl.GetSubObject(CaptureObject.Sink) as LMNetSnk;if (_pSink != null){// set some mux settings_pSink.RequireLogin = true;_pSink.UseEncryption = LMNetSnkLib.NetSnk_Encryption.NetSnk_Encryption_None;// clear all user registrations_pSink.RemoveAllUsers();// setup up user loginsAddModifyUsers();// enumeration usersEnumerateUsers();// add a restrictionAddRestriction();// test timer for connection checking_serverAndClient.TestTimer.Interval = 10000;_serverAndClient.TestTimer.Start();_serverAndClient.TestTimer.Tick += new EventHandler(ConnectionChecker);}// start capture_captureCtrl.StartCapture(CaptureMode.Video);// we'll loop on the state and pump messages for this example.// but you should not need to if running from a Windows Forms application.while (_captureCtrl.State == CaptureState.Running|| _playCtrl.State == PlayState.Running){Application.DoEvents();}// release the mux and demux COM objectsif (_pMux != null)Marshal.ReleaseComObject(_pMux);if (_pSink != null)Marshal.ReleaseComObject(_pSink);}}catch (Exception ex){Console.WriteLine(ex.Message);_result = false;}}private void AddModifyUsers(){// early out if we could not get the sink interfaceif (_pSink == null)return;// get the current connection list versionint oldVers = _pSink.ConnectionVersion;// add a user_pSink.AddUser("User1", "P12345");// get the current connection list versionint newVers = _pSink.ConnectionVersion;// add another user_pSink.AddUser("User2", "P67890");// find a userint user1Id = _pSink.FindUser("User1");// set user 1's password -- was set above in the AddUser call// but we will change it here for demonstration purposes_pSink.SetPassword(user1Id, "P99999");// remove User2 from the registered users listint user2Id = _pSink.FindUser("User2");_pSink.RemoveUser(user2Id);}private void EnumerateUsers(){// get the current user countint userCount = _pSink.UserCount;// verify that we have two users now_result = (userCount == 1);// demostrate enumeration registered usersfor (int i = 0; i < userCount; i++){// do something with user names and passwordsstring userName = _pSink.GetUsername(i);string passWord = _pSink.GetPassword(i);}}private void AddRestriction(){// add a restriction to the client which has the IP = 10.0.0.5// this will not allow a connection from this address.// get number of restrictionsint oldRestCount = _pSink.RestrictionCount;// Number of restrictions we have.int restrictCount = _pSink.AddRestriction("10.0.0.5");// get number of restrictionsint newRestCount = _pSink.RestrictionCount;// verify that we have a new restriction count_result &= (oldRestCount != newRestCount);// enumeration restrictions (demonstration purposes)for (int i = 0; i < restrictCount; i++){string restAddress = _pSink.GetRestriction(i);// do something with Restriction}// find our restriction we added aboveint restriction = _pSink.FindRestriction("10.0.0.5");// remove it_pSink.RemoveRestriction(restriction);// remove all restrictions (demonstration purposes)_pSink.RemoveAllRestrictions();}void CaptureCtrl_Started(object sender, EventArgs e){StartClient();}private void StartClient(){try{// connect a client_playCtrl.SourceFile = _networkAuthenticatedUrl;}catch (Exception ex){_result = false;Console.WriteLine("Player (Client) Exception: {0}", ex.Message);}}void ConnectionChecker(object sender, EventArgs e){_serverAndClient.TestTimer.Stop();// get number of users connected to the serverint connCount = _pSink.ConnectionCount;// get the first connection (demonstration purposes)ILMNetSnkConnection pcon = _pSink.FindConnection(1);// release it -- it is a COM object you know!Marshal.ReleaseComObject(pcon);// get the first connectionpcon = _pSink.FirstConnection;// check all connections with the serverwhile (pcon != null){ILMNetSnkConnection pnext = pcon.NextConnection;long id = pcon.ID;string userName = pcon.Username;string connAddr = pcon.Address;// check if connection is enabled or not// it should be, we just enabled it abovebool enabled = pcon.Enabled;// is it connectedbool connected = pcon.Connected;// check if this connection is disabled// and disconnect it if soif (enabled == false){// close this connectionpcon.Close();}Marshal.ReleaseComObject(pcon);pcon = pnext;}// close all connections (demonstration purposes)_pSink.CloseAll();_serverAndClient.TestTimer.Start();}private void PlayCtrl_MediaEvent(object sender, MediaEventArgs e){if (e.eventCode == MediaEventCode.EC_COMPLETE)_result &= true;}