 			{
 				disposeObjects(stateLog);
 				stateLog = null;
+			}
+		}
+		//If the Session state changes in anyway, a diff is created and stored in the
+		//StateLog history. The latest entry is than sent to the server, to be sent
+		//to everyone else to update their collaboration session.
+		private function handleStateChange():void
+		{
+			// note: this code may need to be changed later if SessionStateLog implementation changes.
+			if (connectedToRoom && stateLog != null)
+			{
+				var log:Array = stateLog.undoHistory;
+				if (synchronizingIncomingDiff)
+				{
+					log.pop(); // suppress the outgoing diff that results from an incoming diff
+				}
+				else
+				{
+					var entry:Object = log[log.length - 1];
+					sendSessionStateDiff( entry.id, entry.forward );
+				}
 			}
 		}
 		

		//Handles Sending the entire session state. Should only be used if
		//someone needs a hard reset, or joining the collaboration server
		//for the first time.
		public function sendFullSessionState( diffID:int, diff:Object, target:String=null ):void
		{
			var message:FullSessionState = new FullSessionState(diffID, diff);
			sendEncodedObject( message, target );
		}
		
		//Handles sending session state changes
		public function sendSessionStateDiff( diffID:int, diff:Object, target:String=null ):void
		{
			var message:SessionStateMessage = new SessionStateMessage(diffID, diff);
			sendEncodedObject( message, target );
		}
		
		//When a message is recieved pass it on to the user

							for (i = stateLog.undoHistory.length - 1; i >= 0; i--)
								setSessionState(root, stateLog.undoHistory[i].backward, false);
							
							//dispatchLogEvent('\nINCOMING ' + userAlias + '.' + ssm.id + ' ' + ObjectUtil.toString(ssm.diff) + '\n--------------------------\n');
							
							// apply remote change
							setSessionState(root, ssm.diff, false);
							
							// replay local changes
							for (i = 0; i < stateLog.undoHistory.length; i++)
								setSessionState(root, stateLog.undoHistory[i].forward, false);
							
							// this will compute the diff and trigger handleStateChange()
							synchronizingIncomingDiff = true;
							stateLog.synchronizeNow();
							synchronizingIncomingDiff = false;
						}
					}
				}
