In this tutorial, we will practice with WebSocket, we will work on the collaborative drawing app as we did in the lecture. We will start with an incomplete version of it and add features to it. Try to avoid look at the lecture example as much as you can.
echoServerBroadcast.js
, note that this file has
two servers implemented in it: one WebSocket
server and one Express.js server server static content. Replace the
port numbers with the port numbers that are assigned to you
according to ports.txt.static/draw.html
, understand the code and
replace the port number with your own port numbers.http://cslinux.utm.utoronto.ca:XXXXX/draw.html
in your
browser, where XXXXX is the port number of your Express.js server.
Note that you need to visit "http" rather than "https". Open it in
multiple browser windows to see how it works collaboratively.echoServerBroadcast.js
so that all clients see the all things that have been drawn so
far.draw.html
. After clicking on this
button, moving mouse over the canvas will erase content from all
clients' canvases. Clicking on "toggle eraser" again will switch back
to the normal drawing mode. Hint: the erase function can be
implemented as drawing white rectangles with predefined size.