{"id":157,"date":"2011-08-13T19:15:42","date_gmt":"2011-08-14T00:15:42","guid":{"rendered":"http:\/\/trillworks.com\/nick\/?p=157"},"modified":"2012-04-10T23:46:30","modified_gmt":"2012-04-11T04:46:30","slug":"pillowchat-how-not-to-build-a-chat-room-with-jquery-phpillow-and-couchdb","status":"publish","type":"post","link":"https:\/\/trillworks.com\/nick\/2011\/08\/13\/pillowchat-how-not-to-build-a-chat-room-with-jquery-phpillow-and-couchdb\/","title":{"rendered":"PillowChat: How Not to Build a Chat Room with jQuery, PHPillow, and CouchDB"},"content":{"rendered":"

After watching J. Chris Anderson show off a CouchDB chat app at an Austin Javascript meeting, I figured Couch might be a good fit for my next large project. Building a clone of my own would be a good way to get familiar with the tech. Since I knew my back end would be PHP, I opted for\u00a0Kore Nordmann’s PHPillow<\/a> wrapper after reading some good things on StackOverflow.<\/p>\n

Here’s the result:<\/p>\n

\"\"<\/p>\n

Structural Overview<\/h2>\n

Client: <\/strong>jQuery runs in the browser, sending messages and polling the server for new ones. Application settings and state are maintained in the global pillowchat object. Functions beginning with “render” read state information from the global and push it into the DOM.<\/p>\n

Server: <\/strong>PHP receives POST requests from the client and handles them in chat.php, sending back JSON messages to the client. There are three CouchDB views defined in views.php for performing the following actions:<\/p>\n