Wednesday, July 7, 2010

CFWebsocket

With the coldfusion community usually being on the cutting edge I was surprised to see that no one had implemented a websocket gateway for coldfusion (that I had seen). So I decided to build a custom coldfusion gateway so people can use coldfusion with websockets. My implementation is based off of TooTallNate's java websocket. http://github.com/TooTallNate/Java-WebSocket . You can access the jar witch contains the .class files and .java files here.

To Use

1. Download JAR, place in coldfusion classpath and restart server.
2. Download the config file, websocket.cfg, from here to serverroot/gateway/config/ . Optionally open file and change port the default is set to 88.
3. Add new gateway type the setup should look like this.
4. Create a new CFC like the one here.
5. Add new gateway instance that should look like
this.
Note: set the CFC path to the cfc you created in step 4.

Your gateway should now be setup for use. The CFEVENT struct in the gateway has a connection attribute which is the websocket connection object which has a .send() method to send data back to the client. In the onclientmessage function of the gateway there is also a message attribute in the CFEVENT struct that contains the message sent from the client. I should soon be uploading a chat application using this gateway to show how an application could be made. Also I have not load tested this or used it in a production environment so use at your own risk!

1 comments:

  1. ansolasJan 25, 2012 03:23 AM
    http://content.juliangautier.com/gatewaytype.png

    picture broken
    ReplyDelete