[Node.js] 실시간 멀티채팅 구현하기!  - http://jinblog.kr/156

Node.js - https://nodejs.org/en/

Socket.io - https://socket.io/

Github 공개된 소스 : https://github.com/devjin0617/nodejs-socket.io-chat-example


this is chat example using nodejs with socket.io

how to run

npm module install:

console$ cd /path/to/project
console$ npm install
  1. start socket.io server

using port 50000

console$ npm run socket
  1. start simple web server
console$ npm run web

using port 8000

  1. open your browser and connect to localhost:8000


Posted by 홍반장水 홍반장水

[NodeJS] Realtime Chat with Node.js


In this tutorial, we are going to build a realtime chat system with Node.js and the socket.io library. The chat permits users to create private chat rooms that they can share with a friend. For avatars, we will use gravatar. You can run the chat locally with node, or push it to heroku or a different cloud service provider.

The code

You can grab the source code from the download button above. It has plenty of comments and is easy to follow. Start with the app.js file and read from there. Here are a few things to look for:

  • All dependencies are declared in the package.json file. They are not included in the zip and you will have to run npm install to get them.
  • We are using separate JavaScript files for the configuration and routes, to make the code more manageable.
  • In the routes file, socket.io stores the username, avatar and room of the person as properties of the socket object itself. This saves us a lot of code and makes managing rooms easy.
  • We use socket.io‘s rooms feature to isolate one chat from another, which is exactly what that feature was developed for.
Enter your name to chat

Enter your name to chat

Posted by 홍반장水 홍반장水