JSValueRef NX::Globals::Net::Get (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef * exception) { NX::Context * context = Context::FromJsContext(ctx); if (auto Net = context->getGlobal("Nexus.Net")) { return Net; } return context->setGlobal("Nexus.Net", JSObjectMake(context->toJSContext(), context->nexus()->defineOrGetClass(NX::Globals::Net::Class), nullptr)); }
return constructor; }, nullptr, kJSPropertyAttributeNone}, {"UDPSocket", [](JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) -> JSValueRef { NX::Context *context = Context::FromJsContext(ctx); if (auto val = context->getGlobal("Nexus.Net.UDPSocket")) return val; JSObjectRef constructor = NX::Classes::IO::Devices::UDPSocket::getConstructor(context); context->setGlobal("Nexus.IO.UDPSocket", constructor); return constructor; }, nullptr, kJSPropertyAttributeNone}, { "TCP", [](JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) -> JSValueRef { NX::Context * context = Context::FromJsContext(ctx); if (auto TCP = context->getGlobal("Nexus.Net.TCP")) return TCP; JSObjectRef tcpObject = JSObjectMake(ctx, context->nexus()->defineOrGetClass(NX::Globals::Net::TCPClass), nullptr); context->setGlobal("Nexus.Net.TCP", tcpObject); return tcpObject; }, nullptr, kJSPropertyAttributeNone }, { "HTTP", [](JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) -> JSValueRef { NX::Context * context = Context::FromJsContext(ctx); if (auto HTTP = context->getGlobal("Nexus.Net.HTTP")) return HTTP; JSObjectRef tcpObject = JSObjectMake(ctx, context->nexus()->defineOrGetClass(NX::Globals::Net::HTTPClass), nullptr); context->setGlobal("Nexus.Net.HTTP", tcpObject); return tcpObject; }, nullptr, kJSPropertyAttributeNone }, { nullptr, nullptr, nullptr, 0 } };