A simple web chat based on socket.io and Node.js
- Node.js - JavaScript runtime Server
- Express.js - Web framework
- HandleBars - View Engine
- Socket.io - Real Time Engine based on WebSockets
- Bulma - CSS framework.
$ npm install
$ npm start
$ open http://localhost:3000/
Open the browser http://localhost:3000.
Understand the basic data exchange between server and client using socket.
We'll undestand how Node.js deals with events and exchange data.
We'll send random data and percieve the "real time" feeling.
Finally. Here's the chat:
- sending data from html from input
- broadcast data back to all clients
Replace this code on your index.hbs file at: views/index.hbs
<section class="section">
<div class="container-fluid">
<h1 class="title">
{{title}}
</h1>
<p class="subtitle">
welcome to {{title}}!
</p>
<div class="content" id="message"></div>
<hr>
<div class="field">
<div class="control">
<input class="input is-primary is-medium" type="text" name="message" placeholder="type your message">
</div>
</div>
<button class="button is-primary">Send Message</button>
</div>
</section>
Get in touch with me.