Games, chat, and finance - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Games, chat, and finance

Description:

Sudoku. Service. Game 1. Avatar. Agent 1. Client 1. Resin. Broker. Client 2. Client. Agent 1 ... sudoku_at_caucho.com/3. First component: service name (sudoku) ... – PowerPoint PPT presentation

Number of Views:187
Avg rating:3.0/5.0
Slides: 31
Provided by: emil5
Category:
Tags: chat | finance | games | sudoku

less

Transcript and Presenter's Notes

Title: Games, chat, and finance


1
Games, chat, and finance Toward a truly
interactive web with Comet, BAM, and HMTP
Emil Ong Chief Evangelist
2
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

3
Groundbreaking Innovations
  • Hessian web services protocol
  • Top clustering implementation
  • Quercus PHP in Java
  • Server-push
  • And now... a revolutionary approach to the
    interactive web

4
The Interactive Web
  • Common properties
  • Sessions are long-lived
  • Must be responsive/ real time
  • Must not overburden server
  • Communication is bidirectional
  • Killer apps
  • Games
  • Chat
  • Finance

5
The Interactive Web with HTTP
  • Sessions are long-lived
  • Must be responsive/real time
  • Must not overburden server
  • Communication is bidirectional
  • This is harder with HTTP

Comet has shown this is possible
6
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?

7
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

8
Techniques compared
9
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

10
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

11
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

12
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

13
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

14
Brokered Agent Messaging (BAM)?
  • Broker
  • Handles communication between
    agents
  • It's not CORBA
  • Agents
  • Represent both clients and services
  • Messaging
  • Messages
  • Request/response (asynchronous)?

15
Example Sudoku
  • Demo

16
Logging In
Resin
Client 1
Login Query
Client Agent 1
Broker
Client Agent 2
Client 2
Login Query
Sudoku Service
17
Starting a game
Resin
Avatar Agent 1
Client 1
Client Agent 1
Start Query
Broker
Game 1
Avatar Agent 2
Client Agent 2
Client 2
Start Query
Sudoku Service
Wait Result
Start Result
Start Message
18
Making a Move
Resin
Avatar Agent 1
Client 1
Client Agent 1
Move Query
Broker
Move Message
Move Result
Game 1
Avatar Agent 2
Client Agent 2
Client 2
Sudoku Service
19
Ending the Game
Resin
Avatar Agent 1
Client 1
Client Agent 1
Move Query
Broker
Move Message
Move Result
Game over Message
Game over Message
Game 1
Avatar Agent 2
Client Agent 2
Client 2
Sudoku Service
20
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

21
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
  • ...

22
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)?

23
Address space
  • Agent names look like email addresses
  • sudoku_at_caucho.com/3
  • First component service name (sudoku)?
  • Second component domain (caucho.com)?
  • Third component instance identifier (/3)?
  • Address structure reflects lightweight nature of
    agents

24
Hessian Message Transfer Protocol(HMTP)?
  • Wire protocol on which BAM is based
  • Uses Hessian for compact serialization
  • Evolved from XMPP (Jabber)?

25
Target platforms
  • Flash/Flex
  • Silverlight
  • JavaFX
  • Java Applets
  • Comet (interim)?
  • Java
  • Quercus (PHP)?
  • .NET

26
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

27
What's next?
  • Technical
  • Convenience functions
  • Making a PHP page a BAM service
  • HMTP standardization
  • Promotional
  • Game contest

28
Thank you!
  • Questions?
  • Comments?

29
More information
  • http//hessian.caucho.com/
  • http//blog.caucho.com /

30
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
Write a Comment
User Comments (0)
About PowerShow.com