games, chat, and finance toward a truly interactive web with comet, bam, and hmtp emil ong chief...
TRANSCRIPT
![Page 1: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/1.jpg)
Games, chat, and financeToward a truly interactive web withComet, BAM, and HMTP
Emil OngChief Evangelist
![Page 2: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/2.jpg)
Caucho Technology
Resin has been around for 10 years Over 8000 customers, even more open source
users User base consists of both early and
conservative adopters Now the top Java web server in NetCraft
http://survey.netcraft.com/Reports/200805/ 340,000 domains
![Page 3: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/3.jpg)
Groundbreaking Innovations
Hessian web services protocol Top clustering implementation Quercus: PHP in Java Server-push And now... a revolutionary approach to the
interactive web
![Page 4: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/4.jpg)
The Interactive Web
Common properties
1) Sessions are long-lived
2) Must be responsive/ real time
3) Must not overburden server
4) Communication is bidirectional
Killer apps Games Chat Finance
![Page 5: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/5.jpg)
The Interactive Web with HTTP
1) Sessions are long-lived
2) Must be responsive/real time
3) Must not overburden server
4) Communication is bidirectional This is harder with HTTP
Comet has shown thisis possible
![Page 6: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/6.jpg)
Simulating Bidirectional Communication with HTTP
Client generated events are easy They are simply requests
AJAX just makes those requests without changing the page
What about the other direction?
![Page 7: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/7.jpg)
Sending events from server to client using HTTP
Polling Requests at regular intervals that complete
immediately Long Polling
Requests that wait for the next event, then restart Server-push (Comet)
Socket held open with streaming updates from the server
![Page 8: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/8.jpg)
Techniques compared
Advantages Disadvantages
Polling ● Easy to do inbrowser now
● Event impedancemismatch
● Socket construction/teardown
Long Polling ● Easy to do inbrowser now
● Less likely to missevents
● Taxes most currentservers
● Socket construction/teardown
Server Push ● Possible in browsernow
● Unlikely to missevents
● Many servers notprepared
● No standardprogramming model
![Page 9: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/9.jpg)
Server-Push (Comet)
Current hot technology Implementations
Resin Grizzly (Glassfish) Jetty Tomcat
All solve the problem of threads dedicated to a socket
All have a different programming model
![Page 10: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/10.jpg)
The problem of Bidirectional Communication with HTTP
Different techniques for send and receive Use AJAX to send data from client Use Comet to receive data on client
Two connections required* Places limitations on TCP that were necessary
for scalability in the past A necessary evil at the moment
![Page 11: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/11.jpg)
Truly Interactive Communication
Must be capable of long-lived connections Must be responsive/real time Must not overburden server Must be bidirectional Must have a simple, coherent API/architecture
![Page 12: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/12.jpg)
Creating the architecture
Start with the communication patterns Messages Request/response
Truly bidirectional communication Client -> Server Server -> Client Both must be supported in both patterns
![Page 13: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/13.jpg)
Creating the architecture
Representation of entities Agents
Bidirectional communication implies that clients are first class citizens
Agents represent both clients and servers A broker manages communication between
agents
![Page 14: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/14.jpg)
Brokered Agent Messaging (BAM)
Broker Handles communication between
agents It's not CORBA
Agents Represent both clients and services
Messaging Messages Request/response (asynchronous)
![Page 15: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/15.jpg)
Example: Sudoku
Demo
![Page 16: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/16.jpg)
Client 1
Resin
Broker
Client 2
LoginQuery Client
Agent 1
LoginQuery
ClientAgent 2
Logging In
SudokuService
![Page 17: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/17.jpg)
Game 1
AvatarAgent 1
Client 1
Resin
Broker
Client 2
ClientAgent 1
ClientAgent 2
SudokuService
StartQuery
WaitResult
StartQuery
AvatarAgent 2
StartResultStart
Message
Starting a game
![Page 18: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/18.jpg)
Game 1
AvatarAgent 1
Client 1
Resin
Broker
Client 2
ClientAgent 1
ClientAgent 2
SudokuService
MoveQuery
AvatarAgent 2
MoveMessage
MoveResult
Making a Move
![Page 19: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/19.jpg)
Game 1
AvatarAgent 1
Client 1
Resin
Broker
Client 2
ClientAgent 1
ClientAgent 2
SudokuService
MoveQuery
AvatarAgent 2
MoveMessage
MoveResult
Game overMessage
Game overMessage
Ending the Game
![Page 20: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/20.jpg)
Design notes
Agents can be long-lived SudokuService Client
Agents can be short-lived SudokuAvatar
Agents are lightweight and dynamic Non-agents can interact with the system
SudokuGame
![Page 21: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/21.jpg)
Code sample: SudokuAvatar
public boolean sendQuerySet(long id, String to, String from, Serializable value) { if (value instanceof MoveQuery) { MoveQuery query = (MoveQuery) value; MoveResult result = _game.move(query, getJid());
_broker.sendQueryResult(id, from, to, result); return true; ...
![Page 22: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/22.jpg)
BAM API
void sendMessage(String to, String from, Serializable value)
boolean sendQueryGet(long id, String to, String from,
Serializable query)
boolean sendQuerySet(long id, String to, String from, Serializable query)
![Page 23: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/23.jpg)
Address space
Agent names look like email addresses: [email protected]/3
First component: service name (sudoku) Second component: domain (caucho.com) Third component: instance identifier (/3) Address structure reflects lightweight nature of
agents
![Page 24: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/24.jpg)
Hessian Message Transfer Protocol(HMTP)
Wire protocol on which BAM is based Uses Hessian for compact serialization Evolved from XMPP (Jabber)
![Page 25: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/25.jpg)
Target platforms
Flash/Flex Silverlight JavaFX Java Applets Comet (interim) Java Quercus (PHP) .NET
![Page 26: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/26.jpg)
Conclusion
Interactive applications will become more common
HTTP is not sufficient to handle them BAM outlines a new architecture and API to
make the development of these applications easier
![Page 27: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/27.jpg)
What's next?
Technical Convenience functions Making a PHP page a BAM service HMTP standardization
Promotional Game contest
![Page 28: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/28.jpg)
Thank you!
Questions? Comments?
![Page 30: Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist](https://reader035.vdocument.in/reader035/viewer/2022070305/551404d7550346e2488b4aae/html5/thumbnails/30.jpg)
Appendix: Bridging BAM and Comet
Initial Comet request creates agent Agent triggers event to client on messages On AJAX requests, pull agent name from
session