How can I get an Electron and Socket.io app to run in a thin client architecture? - node.js

I created an Electron for a tiny company that connects to a Socket.io server. This app obtains the username of the logged in user and the MAC address and sends this info to the server for processing. All of this is working fine with regular desktops. Now, another company wants the same app, but they have a thin client architecture. Is there a way to get the app to run in this kind of architecture?
I am having a hart time figuring it out. I have never dealt with thin clients.
1) In the thin client architecture, would I have my socket.io server code and the app in the same server then? If they are in the same server, how could I get the app to connect to the socket.io server? They are in the same machine, so I am confused.
2) One problem is the app can't obtain the MAC of the thin client because once executed from the thin client it will end up getting the MAC of the server. Is there a way to obtain the MAC of the thin client using Node.js? Is there another way of using Node to recognize some sort of id for the thin client?
I would like the thin client to log in to the server, execute my app automatically, connect to the socket.io server, and send to it the username of the logged in user and the MAC address of the thin client. Is this possible? Do you have any suggestions on how to accomplish this?

You have to use the serverside code of the library for your server. E.g. node express.
Then you have to use the client side code of the library in a client side application. E.g. electron
Electron is a combination of node and chromium and you have to install the final build on the clients machine(s).
Of course, you can do all the things you ask about. Just read the socket.io docs. Its very easy, you can do it by specifying the host IP and listening/emitting events.

Related

Socket.io, Unreal, & Heroku (Node js) : Client not connecting to server?

I'm currently working on a game that connects to a Node.js server for multiplayer data.
The game is developed in Unreal Engine 4 and uses the Socket.io plugin to connect to the Node.js server (cors, express being used).
Everything works locally. So now I'm trying to move on to hosting the server remotely and connecting the unreal client to the remote Node.js server.
I looked into Heroku and set myself up, everything is working fine on its end to my knowledge - I created a tester page with a success message when you load the URL and that comes through.
My first question is - what am I doing wrong when I use unreal to point the socket.io plugin to the server url?
The socket.io plugin asks for a port #, I've tried the following:
http:/{my server/heroku url}:8080/
http:/{my server/heroku url}:3000/
http:/{my server/heroku url}:18279/ (which was given to me by Heroku).
http:/{my server/heroku url}/
So far the game does not connect to the deployed server, the way it does locally.
Any suggestions on what could be going wrong/what am I failing to do next?
A few things after researching:
I do have http-session-affinity enabled
Since the server is working locally, I'm going to make the assumption that the deployed code is not the issue, and that it has to do with the way I'm trying to connect.
is it possible that I have further authorization to config? Such as allowing the unreal game/client to connect to the server/that the client is being blocked some how?
I figured out the issue, it had to do with how my Node.js server code was calling socket.io.
If you come across this issue please send me a message or comment here and I will be happy to send you the code that worked.

why we use socket.io client we can make app with only using via socket.io server?

I having some doubts that:-
what is need to use the socket.io client we can use only the socket.io server to stop refreshing the app.
what is different between the socket.io client and socket.io server.
check this link
socket-io.client is the code for the client-side implementation of socket.io. That code may be used either by a browser client or by a server process that is initiating a socket.io connection to some other server (thus playing the client-side role in a socket.io connection).
A server that is not initiating socket.io connections to other servers would not use this code. This has been made a little more confusing that it probably should be because when using socket.io, it appears that both client and server are using the same socket.io.js file (because they both refer to a file with the same name), but is not actually the case. The server is using a different file than the client.
From the Github page for socket-io.client:
A standalone build of socket.io-client is exposed automatically by the socket.io server as /socket.io/socket.io.js. Alternatively you can serve the file socket.io.js found at the root of this repository.
Keep in mind that there are unique features that belong to client and server so it should not be a surprise that they use some different code. Though they share code for parsing the protocol and things like that, the server has the ability to run a server or hook into an existing web server and it has methods like .join() and .leave() and data structures that keep track of all the connected sockets and is expected to live in the node.js environment. The client has the ability to initiate a connection (send the right http request), do polling if webSockets are not supported, build on a native webSocket implementation if present, etc....

Is possible to React Native run a socket server?

I'd like to make a app with React-Native that's accept connections from another devices (Desktops or mobiles) through raw tcp sockets (like node's Net API) or WebSockets (like Socket.io). The point is that, socket server must be running on the React-Native's App.
I already tried Socket.io and react-native-tcp, it works when i make the server run on a nodeJS's application and the client on RN's app, but not the reverse.
When i try to import Socket.io and make it listen on a port, a error is raisen, because RN don't have node's http module. Just Socket.io/clients works.
I think that i'm doing something wrong, but is really possible to do that? and what is the best way?
Obs: I'm really new in RN's world.
No, we can't create a server although if we create a server we can't connect any other external applications to the server.
So create a server and deploy it in any could service then use it in your react-native app.

Web Sockets communication using nodejs for connection between a web app and a charging device

I want to create an application in which my web app will work as remote , a node based web socket server will work as CMS(central management system) and an electric vehicle charger which will be my device. I want help in how to send instruction to my device according to the commands i receive from it.
You can use socket.io on your server, it is easy to use and has a socket client implementation in almost languages that exist.

socket.io without running a node server

I have a web application that requires PUSH notifications. I looked into node.js and socket.io and have an example that's working. The question I have is, Is it possible to use socket.io only in my client side JS without running a node.js server?
Can a third party server just send requests to a proxy server and may be socket.io just listens to a port on the proxy server and sends back events to it?
Thanks,
You need a server side technology to send data back and forth via web sockets. Socket.io is a communication layer. Which means, you need to have a server side method to send data.
However,
You can use various third party services to use web sockets and notifications. They are relatively easy to use, and they have support for many other languages.
Check some of these out:
http://pusher.com/
https://www.firebase.com/
http://www.pubnub.com/
https://www.tambur.io/
https://fanout.io/
You don't need to run Node.js to have a real time push notifications. You can use a third party service that does it for you. Most of them are cheap, sometimes free for low traffic instances.

Resources