A real-time, synchronous drawing program by Dan Lynch

UC Berkeley CS 260 homework assignment

This application allows users to draw vector graphics and import images, all while sharing data over a network with collaborative members. The project was written in C++ using BSD sockets, POSIX threads, and OpenFrameworks.

Platform and Implementation

About 3500 lines of C++, using one add-on library from OpenFrameworks, the OSXFileDialog, which is used to open a file browser. All the multi-threading done using POSIX threads library, and the socket programming done using BSD sockets library. All this with an accompanying defined networking protocol to represent every interaction and tool. To keep everything in sync, everything is represented as a packet, even if its a user on his/her own machine. Its all packets;)

To implement file transfers was probably the hardest task, mostly because everything was written from scratch. I defined a custom protocol that basically breaks packets up to less than the maximum TCP packet, and sends over a header packet with a sequence of packets containing the data. The reason I did this is for robustness. I tested it and verified its validity on images, mp3s, and even sending the program through the program itself (and it worked after the transfer).

User Interface

Floating Menu

When the user hits space bar, the floating menu pops up enabling the user to select tools near the cursor. The graphics are all original, and the GUI components are all custom C++ code for this project.

capture.gif - nlynch.com

Here is a general overview of the interface:

userinterface.png - nlynch.com

I learned a great deal about the integration of graphics, threading, and networking. I had a great time defining a protocol for processing commands, and in particular, the file transfer. Additionally, the syncing itself was hard at times, especially when getting into the semantics of the packets and when to store them on the history stack.

I also learned that I probably could have saved a lot of time had I used OpenFrameworks' threading and sockets add-ons. This was very time consuming to write in addition to the user interface and packet structures. In the end, it was well worth it though.