Node.js is an event-driven, non-blocking server-side JavaScript runtime built on Chrome's V8 engine. It allows highly scalable network applications to be built by wrapping non-blocking libraries. Node.js uses an event loop that listens for events like connections, requests, data, and closures and queues callbacks for handling them asynchronously without blocking the main thread. This document provides an overview of Node.js and some of its core modules like Express for building web servers and Socket.io for real-time communication. It also includes examples of using Node.js and these modules to build a collaborative drawing application.
1. Node.js
“This is the node.js project: to provide a purely
evented non-blocking infrastructure to script highly
concurrent programs.” - Ryan Dahl
by Shelly Seroussi & Hannah Kim
15. function onMouseDown(event) {
var point = event.point;
path = new Path();
path.fillColor = active_color_rgb;
path.add(event.point);
// The data we will send every 100ms on mouse drag
path_to_send = {
rgba : active_color_json,
start : event.point,
path : []
};
}
index.html