void VJSNetServerSyncClass::Construct (XBOX::VJSParms_callAsConstructor &ioParms)
{
	VJSNetServerObject	*serverObject;
	
	if ((serverObject = new VJSNetServerObject(true)) != NULL) {

		XBOX::VJSObject	createdObject(ioParms.GetContext());

		createdObject = VJSNetServerSyncClass::CreateInstance(ioParms.GetContext(), serverObject);

		ioParms.ReturnConstructedObject(createdObject);

	} else

		XBOX::vThrowError(XBOX::VE_MEMORY_FULL);
}
void VJSXMLHttpRequest::_Construct(XBOX::VJSParms_callAsConstructor& ioParms)
{
    XMLHttpRequest* xhr=new XMLHttpRequest();
	
    if(!xhr)
    {
        XBOX::vThrowError(VE_XHRQ_IMPL_FAIL_ERROR);
        return;
    }
	
	
    XBOX::VJSObject pData(ioParms.GetContext());
	bool resData;
    resData=ioParms.GetParamObject(1, pData);
	
	if(resData)
	{
		XBOX::VJSValue hostValue=pData.GetProperty("host", NULL);
		XBOX::VString hostString;
		bool hostRes=hostValue.GetString(hostString, NULL);
		
		if(hostRes) //we have a proxy
		{
			XBOX::VJSValue portValue=pData.GetProperty("port", NULL);
			sLONG portLong=0;
			bool portRes=portValue.GetLong(&portLong, NULL);
			
			portLong=(portRes && portLong>0) ? portLong : 80;
			
			//todo : user and passwd
			
			XBOX::VError res=xhr->SetProxy(hostString, portLong);
			
			if(res!=XBOX::VE_OK)
				XBOX::vThrowError(res);
		}
	}
	
    ioParms.ReturnConstructedObject(VJSXMLHttpRequest::CreateInstance(ioParms.GetContextRef(), xhr));
	
}
Beispiel #3
0
void VJSDedicatedWorkerClass::_Construct (XBOX::VJSParms_callAsConstructor &ioParms)
{
    if (!ioParms.CountParams() || !ioParms.IsStringParam(1)) {

        XBOX::vThrowError(XBOX::VE_INVALID_PARAMETER);
        ioParms.ReturnUndefined();
        return;

    }

    XBOX::VString		url;
    bool				reUseContext;
    VJSWorker			*outsideWorker;
    VJSWebWorkerObject	*workerProxy;
    XBOX::VJSContext	context(ioParms.GetContext());
    XBOX::VJSObject		constructedObject(context);

    ioParms.GetStringParam(1, url);
    outsideWorker = VJSWorker::RetainWorker(context);

    if (ioParms.CountParams() < 2 || !ioParms.IsBooleanParam(2) || !ioParms.GetBoolParam(2, &reUseContext))

        reUseContext = false;

    if ((workerProxy = VJSWebWorkerObject::_CreateWorker(context, outsideWorker, reUseContext, url, true)) != NULL) {

        constructedObject = VJSDedicatedWorkerClass::CreateInstance(context, workerProxy);
        workerProxy->fOnMessagePort->SetObject(outsideWorker, constructedObject);
        workerProxy->fOnErrorPort->SetObject(outsideWorker, constructedObject);

    } else

        constructedObject.SetNull();

    ioParms.ReturnConstructedObject(constructedObject);

    XBOX::ReleaseRefCountable<VJSWorker>(&outsideWorker);
}