<cfcomponent
extends="RemoteProxy"
output="false"
hint="I provide remote proxy functionality for the MessageService.">
<cfset THIS.MessageService = APPLICATION.MessageService />
<cffunction
name="AddMessage"
access="remote"
returntype="struct"
returnformat="json"
output="false"
hint="I add a message to the cached message collection.">
<cfargument
name="Message"
type="string"
required="true"
hint="I am the message being added."
/>
<cfset var LOCAL = {} />
<cfset LOCAL.Response = THIS.NewResponse() />
<cfif Len( Trim( ARGUMENTS.Message ) )>
<cfset THIS.MessageService.AddMessage(
Trim( ARGUMENTS.Message )
) />
<cfelse>
<cfset THIS.AddResponseError(
LOCAL.Response,
"Message",
"Message must not be empty."
) />
</cfif>
<cfreturn LOCAL.Response />
</cffunction>
<cffunction
name="GetMessages"
access="remote"
returntype="struct"
returnformat="json"
output="false"
hint="I return the cached message collection.">
<cfset var LOCAL = {} />
<cfset LOCAL.Response = THIS.NewResponse() />
<cfset LOCAL.Response.Data = THIS.MessageService.GetMessages() />
<cfreturn LOCAL.Response />
</cffunction>
</cfcomponent>