We are building an app and we are using phonegap serve to run it as a web app. We also have a mobile version of it.
Correct me if I'm wrong but from what I've learn, phonegap is automatically inserting socket io JS into my index.html file. But we already have the socket io included via the <script></script> tag. So what happened's now is that we got 2 inclusion of socket io js.
So as for performance speaking, we only need to load the socket io once.
Screenshot
https://www.evernote.com/l/AA1k9PiF_bJM3qju6-DeE1ZLwkKV17TVyV8
Related
I have used socket io in react native for some real time functionality. But when generate the release build the socket io is not working. What should be the issue please help. SSL is activated on url.
On debug mode the socket io is working fine.
I'm trying to implement a WebSocket server on my UWP app. Something similar to this plugin for Android and iOS, or Chrome socket server. I've looked into the Universal Windows Platform (UWP) app samples for WebSockets, but the way I understand it, it can be used as a Client side, while the Server is run separately using a PowerShell script.
My app is built with HTML and Javascript (AngularJS), compiled with Cordova framework and I wanted a WebSocket Server to run on it so that outside clients would be able to send commands to the app.
Is there any such way (or similar to it) to do this (to receive commands via TCP, etc)?
I am trying to learn how to use Node.js and web sockets to create simple multi-user interactive javascript programs. I used this tutorial series by Daniel Shiffman to create this example project. My next step would be to upload it, using WinSCP, to my RaspberryPi apache2 web server, but I haven't found a way to edit the code in a way to allow for that to work, and furthermore, I do not know what piece of the programs to execute to make it function properly.
Any assistance would be great. The extent of my Node / Socket.io knowledge comes entirely from the video series mentioned above, so you can assume I know almost nothing else.
Apache is a web server and it serves your file and send them to client for you, so when you have some client side things like html site with some css, javascript and images you can use apache to send them to client for you.
In node.js you can create this web server simply by following code and express library:
// Create the app
var app = express();
// Set up the server
var server = app.listen(3000, () => {
console.log('http server is ready')
});
as you created in your code too. by this web server you can host your files and do many more things like setup socket.io server and ... because you write web server yourself. with following code you serve static files in public directory (html, css, javascript and images ...):
app.use(express.static('public'));
after you finishing this process you can run it simply by:
npm install
node server.js
if you want you can run you code inside docker by creating Dockerfile and ...
About your question, you must move all your project files into raspberry and at the end you have following directory tree in somewhere in raspberry:
|- server.js
|- package.json
\ public
at this directory run above commands and your server will be up and running and you can access to it by http://raspberry_ip:3000.
I want to go www.mymagentostore.com/design and start running the node.js application. This application will produce a list of products, will add them to the cart and will redirect the user back to the store or to the checkout page.
I am not sure on how to implement this? Could you please advise, suggest or point to the example?
my thoughts:
1. Run www.mymagentostore.com on port 5000
2.once design button is clicked redirect user to www.mymagentostore.com/design on port 7777
3. Express framework on Node will listen on this port 7777 and route , will run the app , produce results, and will redirect back to www.mymagentostore.com on port 5000
Some questions arise if I think of implementation above:
Can I run php server on one port and node server on another one?
Can I run magento and node on the same domain name?
Will magento router cause problems for node router listener?
You can accomplish this via proxying in your webserver.
You can setup a directory alias in your webserver and have it proxy to the node.js app.
An example: How to rewrite / proxy an Apache URI to an application listening on a specific port / server?
I want to use Node.js run as a back-end server to serve front-end socket.io request.
The samples I found, seems can only run pages from Node.js server.
<script src="/socket.io/socket.io.js"></script>
The above js include is served by Node.js, how to include it if the front-end is a different application (e.g. PHP or static pages) ? Do I need to include all the dependent socket.io js libraries to make it work?
I'm currrently running apache/php alongside node.js/socket.io
If this is what you're trying to do, you can do it by serving socket.io on a different port than what apache is serving on (assumed 80).
In node.js, initialize the socket.io listener on a port 8080 for example:
var io = require('socket.io').listen(8080);
I believe, by default, socket.io will also serve its static client side files conveniently for you, such that in you html, you can:
<script src="http://yourhost:8080/socket.io/socket.io.js"></script>
Hope that helps.
It all depends on your server configuration. You may choose a path to Node.js backend that is not used by any other resource, and configure your web-server to serve everything else.
E.g. for Apache I used ProxyPass directive to enable connections to a local Node.js on a different port (to bypass local port restrictions), though may be not an option for your purposes:
ProxyPass /help/server/ http://localhost:8002/ connectiontimeout=1500ms