diff --git a/index.html b/index.html
index 46873a1..d761979 100644
--- a/index.html
+++ b/index.html
@@ -1,9 +1,39 @@
+
+
+ Chat App
+
- Hello Marx from index.html file
- This is some text
+ A new Chat App
+
+
+
+
-
+
diff --git a/index.js b/index.js
index 2cd03b2..8f2f814 100644
--- a/index.js
+++ b/index.js
@@ -13,6 +13,15 @@ app.get('/', (req, res) => {
io.on('connection', (socket) => {
console.log('A new user is connected');
+ // disconnect
+ socket.on('disconnect', () => {
+ console.log("A user has been disconnect");
+ });
+ // more functions
+ socket.on('chat message', (msg) => {
+ console.log(msg);
+ io.emit('chat message', msg);
+ });
});
server.listen(3333, () => {
diff --git a/package.json b/package.json
index 01346ab..2d4a966 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,12 @@
{
- "name": "nodejs-first-example",
+ "name": "A chat application",
"version": "1.0.0",
- "description": "",
+ "description": "A simpel chat application using express and socket.io",
"main": "index.js",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "start": "node index.js",
+ "dev": "nodemon index.js"
},
"keywords": [],
"author": "",
@@ -12,5 +14,8 @@
"dependencies": {
"express": "^4.22.3",
"socket.io": "^4.8.4"
+ },
+ "devDependencies": {
+ "nodemon": "^3.1.14"
}
}