Refer below article for detail guidance (Recomended),
https://medium.com/@shamique/simple-chat-application-using-ionic-and-socket-io-82d9b4605cc3
- NodeJs & ionic 2 installed in the machine
- Create a directory for chat server and go to that folder
- run
npm init
and initiate a new NodeJs project - Install socket.io:
npm install socket.io --save
- Create filename as server.js and add below code in it
- Run the chat server:
node server.js
var socket = require('socket.io'), http = require('http'),
server = http.createServer(), socket = socket.listen(server);
socket.on('connection', function(connection) {
console.log('User Connected');
connection.on('message', function(msg){
socket.emit('message', msg);
});
});
server.listen(3000, function(){
console.log('Server started');
});
- Clone the repo to your machine
- Go to the project folder and run
npm install
- run the project,
ionic serve