I'm trying to start a nodejs server alongside my panel. According to the tutorial on https://medium.com/adobetech/how-to-build-a-node-js-server-in-a-panel-ba1d63ea67e2 I should be able to accomplish this via using an invisible html page that loads the nodejs server.
I've tried this, but I can't get it to load, and I don't get a lot of feedback on this, so I'm thinking it fails on the actual loading of the extension with CSInterface.
manifest.xml: contains both the main extension as well as the server extension. Nodejs and mixed content enabled on both
<?xml version="1.0" encoding="UTF-8"?>
<ExtensionManifestVersion="9.0"ExtensionBundleId="com.Limecraft.Panel"ExtensionBundleVersion="1.0.0"
ExtensionBundleName="LimecraftPanel"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ExtensionList>
<ExtensionId="com.LimecraftPanel.extension"Version="1.0"/>
<ExtensionId="com.LimecraftPanel.server"Version="1.0"/>
</ExtensionList>
<ExecutionEnvironment>
<HostList>
<HostName="PPRO"Version="13.0"/>
</HostList>
<LocaleList>
<LocaleCode="All"/>
</LocaleList>
<RequiredRuntimeList>
<RequiredRuntimeName="CSXS"Version="9.0"/>
</RequiredRuntimeList>
</ExecutionEnvironment>
<DispatchInfoList>
<ExtensionId="com.LimecraftPanel.extension">
<DispatchInfo>
<Resources>
<MainPath>./client/html/index.html</MainPath>
<ScriptPath>./jsx/index.jsx</ScriptPath>
<CEFCommandLine>
<Parameter>--allow-file-access</Parameter>
<Parameter>--allow-file-access-from-files</Parameter>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>true</AutoVisible>
</Lifecycle>
<UI>
<Type>Panel</Type>
<Menu>Limecraft Flow</Menu>
<Geometry>
<Size>
<Height>600</Height>
<Width>600</Width>
</Size>
</Geometry>
</UI>
</DispatchInfo>
</Extension>
<ExtensionId="com.LimecraftPanel.server">
<DispatchInfo>
<Resources>
<MainPath>./client/html/localServer.html</MainPath>
<CEFCommandLine>
<Parameter>--allow-file-access</Parameter>
<Parameter>--allow-file-access-from-files</Parameter>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>false</AutoVisible>
</Lifecycle>
<UI>
<Type>Custom</Type>
<Icons/>
</UI>
</DispatchInfo>
</Extension>
</DispatchInfoList>
</ExtensionManifest>
index.html: The main page of the app. This one works as normal. It loads the CSInterface.js & jquery, and should open the server extension as written in the manifest, but I'm pretty sure it's this step that doesn't work. Not getting any feedback whatsoever here.
<!doctypehtml>
<html>
<head>
<metacharset="utf-8">
<title>Limecraft Flow - Login</title>
<scriptsrc="../../lib/CSInterface.js"></script>
<!-- <script src="./js/app.js"></script>-->
<scriptsrc="../../lib/jquery-1.9.1.js"></script>
<script>
//Open server extension
console.log("opening server extension")
console.log(__dirname + '\\client\\html\\testnode.js');
varcsInterface = newCSInterface();
csInterface.requestOpenExtension("com.LimecraftPanel.server");
</script>
localServer.html : Should get loaded via the CSInterface script, but no logs get triggered, and most likely doesn't get loaded at all.
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8">
<!-- <script src="testnode.js"></script> --><!-- Tried loading it like this, but also no feedback, so pretty sure this file doesn't get loaded. -->
<script>
/*As you can see in the <MainPath> tag of the manifest.xml above, when a CEP method is called in your JavaScript file,
another HTML markup will be loaded from ./client/localServer.html.
Note that we addedlocalServer.html` when we updated the directory structure.
You might wonder why you have to write another HTML file for the server extension.
The purpose of this HTML file is to start your server and stay hidden.*/
/* This script uses cep_node to start the Node.js server located at '/server/main.js' */
console.log("=============================");
console.log("SETTING UP LOCAL SERVER");
varlocalServer = cep_node.require(__dirname + '\\client\\html\\testnode.js')();
</script>
<title>node server app</title>
</head>
<body>
</body>
</html>
testnode.js : The testcode for the server, this one works both via terminal command as well as via loading it directly via <script> tag in the main app, meaning it most likely just doesn't get loaded along with the LocalServer.html
consthttp = require('http');
consthostname = '127.0.0.1';
constport = 3000;
constserver = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
the localserver doesn't get loaded via any means,leading me to believe that this is some problem with CSInterface or a fault in my manifest.xml code, but I see nothing I'm doing wrong here. Am I missing something?