Open CF Summit 2012
Billy Cravens
   Billy Cravens
   ColdFusion since 4.0 (1999)
   Houston CFUG manager
   Former DFWCFUG board member
   Other languages: PHP, .NET; node.js ninja in
    training
   Remember the Wrox book?
   Supporter of Cystic Fibrosis
     www.CureCF.com
   Full-blown training on WebSockets
   Limited to only open source engines
   A spectacular demo – we’ll look at bare bones
    chat implementation
     “I hate chat app examples”
                   - Ray Camden
   In-depth knowledge of OSS roadmaps
   An overview of options in all available CFML
    engines
   Highlight the role of open source solutions
    across this entire space
   A review of the landscape on February 25,
    2012
   Polling
   Long-polling / Comet
   Flash
   What are they?
     ▪ Bi-directional, full duplex TCP communication in the
       browser
     ▪ Not finalized – multiple versions
     ▪ ws(s)://serviceURI(:port)(/optional/path)
     ▪ Client side: JavaScript
   Support
     Browsers that support WebSockets
      ▪ IE 10+, FF 6+, Chrome 14+, iOS 4.2+, BB OS7
     Using Flash and JavaScript as polyfill
      ▪ https://github.com/gimite/web-socket-js
      ▪ The code
   node.js/socket.io
     WebSockets + evented JavaScript
     Complexity
   PusherApp
     Hosted service
     Dependent
   ColdFusion < v.10
   Railo
   Open BlueDragon
   https://github.com/nmische/cf-websocket-
    gateway

   Built on Netty, non-blocking IO framework
    for Java (similar to node.js)
   Built on Webbit, a Java WebSocket server
   Event gateway
     Copy JARs and restart ColdFusion
     Configure gateway type
     Configure gateway instance
     Create CFC with WebSocket methods
      ▪ Open Connection
      ▪ Close Connection
      ▪ Incoming Message
   Event gateway
     Railo allows for gateways types to be written in
      CFML (ACF=Java)
     Railo has extension API: add gateways, libraries,
      etc, via Admin
     Gateway based on lightweight WebSockets server
      ▪ https://github.com/TooTallNate/Java-WebSocket
   More info
     ▪ http://wiki.getrailo.org/wiki/Extensions:WebSockets_Ga
       teway
   I encountered some errors
     You can report – fast to respond
     You can fix – gateway is in CFML
     Install script is CFML – you can troubleshoot
   I almost made it work
     fix code in install.cfc:
      (railo-root)/WEB-INF/railo/temp/compress/(random
      string)/(UUID)/railo/install.cfc
       ▪ *** didn’t work ***
     manual copy
       ▪ (railo-root)/WEB-INF/railo/temp/compress/(random string)/(UUID)/railo
         WebSocket.cfc and WebSocketListener.cfc
         to (railo-root)/WEB-INF/railo/components/railo/extension/gateway/
       ▪ Then restart
       ▪ Still no WebSocket option in gateways screen
     Moved WebSocketGateway.cfc from (railo root)/WEB-
      INF/railo/context/admin/cdriver to …../gdriver
       ▪ Restarted - this fixed it

     Had to add mapping to components/railo directory
   On to the code ….
   Current release (2.02) added socket functions
   Not so fast …
     Raw TCP Sockets, not WebSockets
     
   Options
     craft handshake yourself
     Use a wrapper:
      https://github.com/kanaka/websockify
     Write a wrapper: tiny little node.js script
   Simple WebSockets support
   Configuration: CF Admin > Server Setting >
    WebSocket
     Port: for WS client
     Socket Timeout
     Max Data Size: default OK for most apps
     Start Flash Policy Server: for Flash fallback
   The code
   Advantages
     Little code
     More open than other approaches (Flash, Blaze
      DS, etc)
   Disadvantages
     Little analysis of the guts
     Beta 1 – probably summer before gold
     Commercial product

Websockets

  • 1.
    Open CF Summit2012 Billy Cravens
  • 2.
    Billy Cravens  ColdFusion since 4.0 (1999)  Houston CFUG manager  Former DFWCFUG board member  Other languages: PHP, .NET; node.js ninja in training  Remember the Wrox book?  Supporter of Cystic Fibrosis  www.CureCF.com
  • 3.
    Full-blown training on WebSockets  Limited to only open source engines  A spectacular demo – we’ll look at bare bones chat implementation  “I hate chat app examples” - Ray Camden  In-depth knowledge of OSS roadmaps
  • 4.
    An overview of options in all available CFML engines  Highlight the role of open source solutions across this entire space  A review of the landscape on February 25, 2012
  • 5.
    Polling  Long-polling / Comet  Flash
  • 6.
    What are they? ▪ Bi-directional, full duplex TCP communication in the browser ▪ Not finalized – multiple versions ▪ ws(s)://serviceURI(:port)(/optional/path) ▪ Client side: JavaScript
  • 7.
    Support  Browsers that support WebSockets ▪ IE 10+, FF 6+, Chrome 14+, iOS 4.2+, BB OS7  Using Flash and JavaScript as polyfill ▪ https://github.com/gimite/web-socket-js ▪ The code
  • 8.
    node.js/socket.io  WebSockets + evented JavaScript  Complexity  PusherApp  Hosted service  Dependent
  • 9.
    ColdFusion < v.10  Railo  Open BlueDragon
  • 10.
    https://github.com/nmische/cf-websocket- gateway  Built on Netty, non-blocking IO framework for Java (similar to node.js)  Built on Webbit, a Java WebSocket server
  • 11.
    Event gateway  Copy JARs and restart ColdFusion  Configure gateway type  Configure gateway instance  Create CFC with WebSocket methods ▪ Open Connection ▪ Close Connection ▪ Incoming Message
  • 12.
    Event gateway  Railo allows for gateways types to be written in CFML (ACF=Java)  Railo has extension API: add gateways, libraries, etc, via Admin  Gateway based on lightweight WebSockets server ▪ https://github.com/TooTallNate/Java-WebSocket
  • 13.
    More info ▪ http://wiki.getrailo.org/wiki/Extensions:WebSockets_Ga teway
  • 14.
    I encountered some errors  You can report – fast to respond  You can fix – gateway is in CFML  Install script is CFML – you can troubleshoot
  • 15.
    I almost made it work  fix code in install.cfc: (railo-root)/WEB-INF/railo/temp/compress/(random string)/(UUID)/railo/install.cfc ▪ *** didn’t work ***  manual copy ▪ (railo-root)/WEB-INF/railo/temp/compress/(random string)/(UUID)/railo WebSocket.cfc and WebSocketListener.cfc to (railo-root)/WEB-INF/railo/components/railo/extension/gateway/ ▪ Then restart ▪ Still no WebSocket option in gateways screen  Moved WebSocketGateway.cfc from (railo root)/WEB- INF/railo/context/admin/cdriver to …../gdriver ▪ Restarted - this fixed it  Had to add mapping to components/railo directory
  • 16.
    On to the code ….
  • 17.
    Current release (2.02) added socket functions  Not so fast …  Raw TCP Sockets, not WebSockets    Options  craft handshake yourself  Use a wrapper: https://github.com/kanaka/websockify  Write a wrapper: tiny little node.js script
  • 18.
    Simple WebSockets support  Configuration: CF Admin > Server Setting > WebSocket  Port: for WS client  Socket Timeout  Max Data Size: default OK for most apps  Start Flash Policy Server: for Flash fallback
  • 19.
    The code
  • 20.
    Advantages  Little code  More open than other approaches (Flash, Blaze DS, etc)  Disadvantages  Little analysis of the guts  Beta 1 – probably summer before gold  Commercial product