Permalink
Browse files

Cleaned up a bit of code for the commit.

  • Loading branch information...
1 parent 8ce0615 commit 4081cd76d5faffd4e7ab10d9cf680d5a89a04b7b @bennadel committed Mar 9, 2012
Showing with 36 additions and 27 deletions.
  1. +1 −1 Application.cfc
  2. +25 −21 WSApplication.cfc
  3. +8 −4 index.cfm
  4. +2 −1 js/main.js
View
@@ -7,7 +7,7 @@ component
// Define the application settings.
this.name = hash( getCurrentTemplatePath() );
- this.applicationTimeout = createTimeSpan( 0, 0, 5, 0 );
+ this.applicationTimeout = createTimeSpan( 0, 0, 20, 0 );
this.sessionManagement = false;
// Set up the WebSocket channels. For this demo, I'm only
View
@@ -4,27 +4,12 @@ component
output="true"
hint="I define the application settings and event handlers."
{
-
-
- function logIt( it ){
-
- var filePath = (getDirectoryFromPath( getCurrentTemplatePath() ) & "log.txt");
-
- writeDump(
- var = it,
- format = "text",
- output = filePath
- );
-
- }
-
-
-
- // Instantiate the Application.cfc that we'll use to process
- // these WebSocket requests. This component (WSApplication),
+
+ // Store an instance of the Application.cfc that we'll use to
+ // process these WebSocket requests. This component (WSApplication),
// gets cached. As such, we'll have to re-instantiate the target
- // Application component at key points in the lifecycle.
+ // Application component at key points during the lifecycle.
this.application = {};
@@ -49,7 +34,7 @@ component
this.application.onWSRequestStart(
"unsubscribe",
requestInfo.channelName,
- requestInfo.connectionInfo
+ this.normalizeConnection( requestInfo.connectionInfo )
);
// Return out.
@@ -61,7 +46,7 @@ component
// I determine if the given user can publish the given information.
function allowPublish( requestInfo ){
- // Re-instantiate the target application.
+ // Re-instantiate the target application.
this.application = new Application();
// Check to see if the application will process this event.
@@ -252,6 +237,25 @@ component
}
+ // ------------------------------------------------------ //
+ // ------------------------------------------------------ //
+
+
+ // I log the arguments to the text file for debugging.
+ function logData( data ){
+
+ // Create a log file path for debugging.
+ var logFilePath = (
+ getDirectoryFromPath( getCurrentTemplatePath() ) &
+ "log.txt"
+ );
+
+ // Dump to TXT file.
+ writeDump( var=data, output=logFilePath );
+
+ }
+
+
}
View
@@ -10,7 +10,7 @@
<html data-app-name="<cfset writeOutput( appName ) />">
<head>
<meta charset="utf-8">
- <title>ColdFusion 10 WebSocket Demo</title>
+ <title>Using ColdFusion 10 WebSockets With RequireJS</title>
<!-- Load the demo styles. -->
<style type="text/css">
@@ -76,7 +76,11 @@
</style>
- <!-- Load the script loader and boot-strapping code. -->
+ <!--
+ Load the script loader and boot-strapping code. In this
+ demo, the "main" JavaScript file acts as a Controller for
+ the following Chat interface.
+ -->
<script
type="text/javascript"
src="./js/lib/require/require.js"
@@ -86,12 +90,12 @@
<body>
<h1>
- Using ColdFusion WebSockets With RequireJS
+ Using ColdFusion 10 WebSockets With RequireJS
</h1>
<div class="chatWindow">
<ol class="chatHistory">
- <!-- Chat history. -->
+ <!-- Chat history will be populated dynamically. -->
</ol>
</div>
View
@@ -12,7 +12,8 @@ require.config({
});
-// Load the application.
+// Load the application. In order for the Chat controller to run,
+// we need to wait for jQuery and the CFWebSocket module be available.
require(
[
"jquery",

0 comments on commit 4081cd7

Please sign in to comment.