This is the node.js
server that creates a websocket from the ws
npm packages. This WebSocket is used for a Flutter application. The app makes it possible to chat on a LAN.
2 main files in the app
folder:
server.js
is used to run the websocket and to listen for incoming connections.client.js
is a client that connects to theserver.js
websocket.- An automatic message is sent whenever there is an succesful connection with the websocket.
git clone
this repocd
into thewebsocket-server
folder- Run
npm install
in command line - Open
app/config/config.js
and fill in your IP and port where the WebSocket should be running - Open
app/client.js
- Run
npm start
, this will execute the commandnodemon ./app/server.js
. Now your WebSocket is running - Run
npm run client ./app/client.js
to establish a connection and send a message
Notes:
- It is possible to change the websocket port in the
server.js
file. - You can find your IP by opening your terminal and type
ipconfig -all
and look for your IPv4 Address.