void VRemoteDebugPilot::HandleDisconnectingState()
{
	XBOX::VError			err;
	VSize					msgLen;
	bool					isMsgTerminated;
	sBYTE*					tmpStr;

	msgLen = K_MAX_SIZE;
	tmpStr = NULL;

	err = fWS->ReadMessage((void*)fTmpData,msgLen,isMsgTerminated);
	if (err)
	{
		DebugMsg("VRemoteDebugPilot::HandleDisconnectingState fWS->ReadMessage pb\n");
		//AbortContexts(true);
		DisconnectBrowser();
		return;
	}
	if (msgLen)
	{
		if (msgLen < K_MAX_SIZE)
		{
			fTmpData[msgLen] = 0;
		}
		else
		{
			fTmpData[K_MAX_SIZE-1] = 0;
		}
		DebugMsg("VRemoteDebugPilot::HandleDisconnectingState received msg(len=%d)='%s'\n",msgLen,fTmpData);
		tmpStr = (sBYTE*)strstr((const char*)fTmpData,K_DBG_PROTOCOL_DISCONNECT_STR);
	}
	else
	{
		XBOX::VTime			curtTime;
		XBOX::VDuration		disconnectDuration;
		curtTime.Substract(fDisconnectTime,disconnectDuration);
		if (disconnectDuration.ConvertToSeconds() > 2)
		{
			tmpStr = fTmpData;
		}
	}
	if (tmpStr)
	{
		//AbortContexts(true);
		DisconnectBrowser();
		return;
	}
}
void VRemoteDebugPilot::VStatusHysteresis::Get(bool& ioConnected)
{
	XBOX::VTime			curtTime;

	curtTime.FromSystemTime();
	fLock.Lock();
	if (ioConnected)
	{
		fLastConnectedTime = curtTime;
	}
	else
	{
		XBOX::VDuration		disconnectedDuration;
		curtTime.Substract(fLastConnectedTime,disconnectedDuration);
		// if disconnection quite recent (< approx 1 s) consider it always connected
		if (disconnectedDuration.ConvertToMilliseconds() < 1100)
		{
			ioConnected = true;
		}
	}
	fLock.Unlock();
	
}