<mySearch ⁄>
<myBlog show="last" ⁄>
<myPhoto order="random" ⁄>
<mySnippets order="rand" ⁄>
<mySnippets type="lang" ⁄>
<myQuote order="random" ⁄>Controle a sua emoção, ou ela o controlará.
<myContacts ⁄><email ⁄>
<windows live messenger ⁄>
<myCurriculum type="pdf" ⁄>
<myVisitorsMap ⁄>Hey everyone! Sorry about the long pause since the last blog post, life has been quite hectic for the past little while. Today we'll be looking at developping collaborative web applications, that is applications which more than one person can interact with the data at the same time. However, we'll be spicing it up a little bit by making it real time, so no need to refresh the page every time you want to see the new data! In order to do this, you'll be needing Node.js and the Socket.IO module (easily installable via the npm tool. Although I don't like having too many requirements for a post, I'll also be using jQuery 1.7.2 in order to facilitate DOM manipulation. Finally, you'll also need some kind of web server (try and implement it in Node for fun!) as we'll encounter some cross-domain constraints if we don't.
So what will we be building today? We'll be building an application which shows a simple task tracking application, which will contain a master list of tasks to be done. We'll also be keeping it simple, so people will be able to add tasks and mark tasks as done. It will update real time, so therefore we will have to make a system which allows us to notify everyone watching the list when a task is added or completed. The list will also have to be sent whenever there is a new visitor for the page in order to make sure they also see all the current tasks. For simplicity's sake, we will be storing the tasks in memory on the server side, however I encourage you to use it as an experiment for connecting Node to a number of different persistence services.
In case you've never worked with Socket.IO before, it is a library which allows us to have two-way real-time communication on a web page. It makes use of a variety of techniques in order to increase the browser compatibility, making use of WebSockets if available and falling back to techniques such as AJAX polling and a Flash socket. If you've ever done socket programming for desktop applications, working with Socket.IO will feel very familiar. If you haven't, have no fear! Messages (packets) are sent back and forth with an identifier. Callbacks for a given identifier are implemented on the receiving end which works with the data. The nice thing about this is that we are using Javascript for both the sending and receiving data. Think of sending a packet like leaving a voicemail: you have a phone number and a message, and if the receiver chooses to receive messages for that phone number, he can work with the message.
este é só um excerto do artigo, para aceder ao artigo completo, clique no link em baixo:
this is just a small excerpt from the article, to access the full article please click in the link below:
http://codingcookies.com/2012/05/01/real-time-applications-with-node-j...
<myNews show="rand" cat="programacao" ⁄>