朝で 4 カ 77 〃肥バ / 4 〃イカ 7 Ⅲ c , , e ル 2 ″ Realtime User Experience 召ⅲ / 市昭 the 0 REILLY 花イ火 0 イ e 〃
Sites -dIIAT&T 2 : 59 PM 33 people on aVC.com monthly max: 156 mon 物ツ min: 0 10 00W -- ーっ 3 可 ng TOP pages 日 og Reading Mainstream ? 隘 d2000 冩 0 , ' 物協 0 イ朝 a は第 0 1 第ⅵ誕ル m ! A VC DigitaI Strangejove A VC 7 2 日 g レ尾 9-2. Monitoring ル訪豆ルわ the C わの - ル e 卍わ 0 〃 e 〃〃わ〃 W0 叩「 a Another service providing realtime analytics tracking is called Woopra ( : 〃ルルル . ル 00 〃 r 砒 CO 川 . This service is alSO installed by adding some JavaScript COde tO a site and then watching the statistics as quickly as they are collected. However, one differ- entiating factor Of Woopra is that it requires users tO install a Java-based desktop application [ 0 monitor the traffic (see Figure 9-3 ). AIthough Woopra lacks the alerting capability of Chartbeat, it does allow website owners tO interact with their users on a very personallevel. From the 、み oopra interface, a 、、一 oopra subscriber can initiate an instant message chat session with any user wh0 is currently viewing the website (see Figure 屮 4 ). ReaItime AnaIytics Services
Realtime Chat F 宿 n ( お s 朝第新 9. Cha ng wRh Frances G ・ 02 も第・ d.. Cha Ⅲ叩 with 0 「 Hi 廿「 e ! C with S 十を h れ p : / ハ謝 h05 む 8888 / 日 g リ尾 6-6. 立怩 ra にわルⅲ do ル 5 ル卍厖り〃ⅲ g 立浦平信 ) 翻 すめ吶可ユ C000 に Acting Natural
user start typing and stop? ls this person still online? These are the types 0f features that change a standard chat script into a living, breathing realtime application. Luckily, with the COde that's already written, these features are easy tO implement. Realtime Chat Ⅱ、十い h p : / / lo ( ho 8888 / Chatting with Paul You: 印 , paul Paul : H 創 0 ! e ()• C00 ( ホ Chatting with = 80 「 You: George! Cant believe you*re on ⅱ冊 ! い記ⅲ 0 新 p : ″ IO ( 引 0 化 888 & 「 . completed 8 0f9 items 影、にコ十 Oh p : ′ / lo ( 謝 h05 を 8888 / with J0hn J0hn: , paul Y にト日 0 ! Realtime Chat e [(q•Google Cha 盟 ng with 30 「 George: What*s with JOhn? You:I know, right? い記 ing 物 p : / ハ 0 ( a 旧 0 式 : 888 引を completed 8 0f9 ms Ⅱ十 = 6 ⅸ tp : / ハ 0 ( 謝 ho 8888 / C hatting w れ JOhn JOhn: George! Cant believe YOLfre on ⅱ ! Yep R 3 m Chat e C000 に Cha れ it w にれ PauI You: What's with John? Paul:I know, right? Loading t ゆ : / ハ 0 ( 3 物 05t : 8888 に ( 0E0 はを d 10 Of 11 ms 日 g Ⅲ℃ 6-4. A 川〃 chatsession ⅲ〃れ市ゆにわ ro ル s 夜・ルⅲ do ル s 122 ー Chapter 6 : Chat
iChat Window G008 厄 GoogleTaIk Server App Engine Cloud XMPP Services YourA 叩 EngineA 叩 XMPPHandIer.post() method Logging inf0 view on Dashboard 日 g 尾 7-11. The 衂川 e 可 e ⅲ 5 厩川お覊 ge 分 ( ) ( ) Chat with instant—messa in ⅲ 5 ね n ト m055 ing@appspot.com 0 bb につマ 0 A きね b 池 9 : 37 PM pps pot 工 0 m HellO 物部 e ! 9 HellO there! Figure 7-12. C わなⅲ g ル〃 myselfvia [ 記翔げ 142 ー Ch 叩 ter 7 : lnstant Messaging
App DetaiIs Website Narne• Which website will you use the AP け 0 「 ? Whatis your website about? Website Description *.com l.e. http://example ℃ om/mobile settings Website URL ① realtimebook Just fO 「 yourr ℃ ference Between 5 and 8 characters. FO ⅱ ncomi 的 and outgoing messages. SMS Prefix•① Examples for Building the Realtime User Experience realtime 日 g ″尾 & 9. R ビ翔ⅲ g たル 0 ル〃 Zeep Mo ん ー Cancel http://instant・ messaging.appspot.com/sms/incoming/via/zeep l.e 、 http://example.com/incoming Where should we send incoming events? CaIIback URL* 0 Sending and Receiving the Messages ー 173 API key and secret. Keep these values handy, as we'll be using them in the code. After reserving your keyword, the Zeep M0bile website greets you with a newly created COde [ 0 quickly determine the source Of each request. created t0 handle all 0f the incoming messages. Changing the service name enables the of the callbacks from the service [ 0 the same SMSIncomingHandIer controller that we
! 5 ted ー 0 れ e obile Activate ド 0b00k Texts ( 5 p 1 of 3 ) P 厄 as に ( h005 に your country and mobile 5 にⅣにに 0 ⅵ de 「 below.* 〔 4 」」」こ」」」」こ : 」イ Choose a carrier 引ま yo リ「 mo を厄 ( を町 ov 電を「 AT&T Verizon Sprint Nextel B00 式 Virgin USA Helio Cellular South T-Mobile CeIIcom リ 0P0 广 them this 朝 N に ーれ 0 ー e COA iOn ( 0 e. 式 ( h 「 92 fO 「 this 5 を「朝 ( 色 5 盟 nd ~ 電 me 3 M を 55a905 Figure 8-7. Entering ツ 0 ″ r ル汁 el い s c のⅵげ 0 れ朝 c 訪 00 た e.dlAT&T 3G Ca Messages 8 : PM 1010100018 CanceI Edit Add to Contacts D00 19 , 2009 8 : 21 PM FRM:troden@neIson.Ioca I(TedRoden) SUBJ:Greetings MSG:SMS from the command line 0 日 g 尾 8-2. The emailed 川お g ビ 0 〃 a 〃わ 0 〃に おト d The 5M5 Landscape ー 155
user types two keys in a row, chances are good that it'll be within that 1.5 second window, and we won t send a notification tO the server. We're not sending a request with every keystroke, because that would be a ton of keystrokes and thus a 10 [ 0f HTTP requests. We can easily determine whether a user is typing and still conserve HTTP requests by giving it a reasonable timeout between keystrokes. Figure 6-5 shows this process. User Keystrokes . seconds . ( ondS First keystro ke Th e last keystro ke more than 1.5 seconds ago Ping/typing on the server Figure 6-5. Waiting 7.5 co 〃ホわ et ル〃尾甲ィなの尾〃 0 なれ e ルた eys ℃たお We're effectively queueing up and sending notifications when one user starts typing to another user. All that's left is [ 0 inform the user on the receiving end. Add the following code into the chat. handle updates method of 訪 : if(message ・ type = ・ login' ) { 'typing' ) { else if(message ・ type / / get the user var u = chat. users[message. data. from user id]; u. panel. setFooter(). user name + ・ is typing ・ / / clear any existing timeouts clearTimeout(chat. timeouts[u. user id]); / / setup a new timeout chat. timeouts[ u. user id] = setTimeout(function() { u. pane1. setFooter(). user_name 十 } , 300 の ; chat. P011 ( ) ; / / keep polling typed ・ Acting Natural ー 125
We've added all of the code needed to secure this form with a password, so now we need tO start the server and test it ou [. From the apps directory, instruct Maven [ 0 start the server: ~ cometd-java/apps $ mvn jetty:run [INFO] Scanning for projects. [INFO] Searching repository for plugin with prefix: 'jetty' . This will compile the newly created filter and then start the server. When you point your web browser t0 the same ⅵ ver-post. html , you'll notice the newly added password field (see Figure 4 ー 8 ). The password we set in the lte て 5. j50 file was 2345 ' '. Try submitting the form bOth with and without the correct password. when the correct password is supplied, the form submits like normal. If the password is wrong, the publish request is silently ignored. 0 0 h p : / ハ 0 ( host : 8080 / 「ⅳ e ← post 、ⅸ m ー 。 - 十 6 http:/ハ」 ho 、 08080 / 0 ⅳ " ー po h 、 e , Goog 厄 Author Password P 55W3- は 2 34 第 Post 日 g 尾 4-8. The 角 r 川↓ⅵ四 ss ル 0 尹 eld 76 ー Chapter 4 : River ofContent
Ted Roden New York 0 0 Away View full profile Get started with G00 e Reader ロ Atom Openlink in new ね b Open ⅱ nk in new wi ndow Open link in incognito window Save link as 、 Copy lnspect element Copylink 記 d “ 日 g 尾 2-6. The A 川を翻ル r S わの℃ d ltems Right-click on that URL and copy thelink. That's the $topic url we're going to request a subscription t0. ln the index. php file, change the line specifying the $topic url to the URL you just copied from Google Reader: $topic url = yo - atom - リⅵ " This file is already capable of subscribing to hubs, but in order to really test this out, we wantto handle the publish requests as well as the subscribe requests. Adding this functionality is very straightforward. For this example, we re Just going to add the shared items from Google Reader as rows [ 0 our entries table from the section on SUP feeds. ln order [ 0 acceptthe publish POST requests from the hub, we're going to need to add a bit more t0 our index. php file. Append this to the end of that file: else if(@$HTTP RAW POST DATA) { / / publish include( ・ db. php'); $db = new db(' syndication test' ・ db_pass ・ ); $xml = simplexml load string($HTTP RAW POST DATA) ; foreach($xml->entry as (e) { $href = false; $links = $e->link; foreach($links as $ 1 ) { 'db user' 34 ー Ch 叩 ter2: ReaItime Syndication