ClearBox Server™ v1.2 Developer's Guide

INASManagement::EnumUsers

Called by server to receive list of users currently connected to the NAS. Then this list is passed to ISynchronizer::Synchronize as usersList array.

HRESULT EnumUsers(
	[out] unsigned long* usersNum,
	[out] USERADDRESS** usersInfo,
	[out] VARIANT_BOOL * statusOK);

Parameters

usersNum
[out] Specifies number of entries in usersInfo array returned by synchronizer object.
usersInfo
[out] Extension must allocate this parameter as an array of entries containing information about users currently connected to NAS specified by nasIPAddress in call to INASManagement::Init.
statusOK
[out] Specifies whether synchronizer object supplies valid list of current sessions (VARIANT_TRUE), or it failed (VARIANT_FALSE).

Return Values

If extension returns error code, server will call this method after time span specified in "Synchronization fail retry interval" server configuration parameter.

Thread Safety

This method is called in context of SYNC thread. (See Server Threads Model for details.) You should synchronize data which is shared with other threads.

Memory Management

Extension may allocate memory for usersInfo calling CoTaskMemAlloc, and it is freed by server.

Remarks

Synchronizer must distinguish two different situations - when it fails to enumerate users due to its internal error and when it cannot connect to a NAS. In fommer case it rather should set statusOK to VARIANT_TRUE assuming that NAS is off or rebooting, and there are no current sessions on this NAS. This will allow server extension clear its table of active users' sessions.

Example Code

This code reports that there 3 users currently connected to NAS with which this synchronizer object is associated, and provides their names and NAS ports.

STDMETHODIMP CSync::EnumUsers(
	unsigned long* usersNum, USERADDRESS** usersInfo,
	VARIANT_BOOL* statusOK)
{
	*usersNum=3;
	*usersInfo=reinterpret_cast<USERADDRESS*>(
		CoTaskMemAlloc(sizeof(USERADDRESS)*3));
	
	(*usersInfo)[0].userName=SysAllocString(L"John");
	(*usersInfo)[0].port=SysAllocString(L"Async11");	

	(*usersInfo)[1].userName=SysAllocString(L"Ted");
	(*usersInfo)[1].port=SysAllocString(L"Async13");	

	(*usersInfo)[2].userName=SysAllocString(L"Bill");
	(*usersInfo)[2].port=SysAllocString(L"Async16");
	
	*statusOK=VARIANT_TRUE;
	return S_OK;
}

See Also

INASManagement, ISynchronizer::Synchronize, Synchronization process


© 2001-2003 XPerience Technologies. www.xperiencetech.com

Created by chm2web html help conversion utility.