1 Replies - 2276 Views - Last Post: 06 March 2009 - 07:56 AM Rate Topic: -----

#1 QuickAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-February 09

XMLSocket Gateway event subscription.

Post icon  Posted 09 February 2009 - 09:52 PM

Hey guys,

i am finding it real hard to find a working model of a xmlsocket connection trough connection trough cold fusion.
The event gateway functions properly as the debugger provides output but my arguments are incorrect but i am unsure as to what they should be subscribe to the CFevent the following code is what i have

			import mx.controls.Alert;
			import flash.net.Socket;
			import flash.net.XMLSocket;
			import flash.events.Event;
			
			
			[Bindable]
			public var _socket:XMLSocket = new XMLSocket("localhost",1225);
			
			[Bindable]
			public var _messages:Array = new Array();
			
			[Bindable]
			public var _connected:Boolean = false;
			
			[Bindable]
			public var nextId:int = 0;
			
			private function init():void
			{
				_socket.addEventListener(DataEvent.DATA,messageHandler);
				_socket.addEventListener(Event.CONNECT,connectionHanlder);
				_socket.addEventListener(IOErrorEvent.IO_ERROR,IOHandler);
				_socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,secureHandler);
				_socket.connect("localhost",1225);
				trace(_socket.connected);
			}
			
			private function messageHandler(event:DataEvent):void
			{
				var xml:XML = new XML(event.data);
				//
				// What is the name of the root element?
				//
				var element:String = xml.name().toString();
				if(element == "response")
				{
					//
					// Swallow this event - for demo just
					// assume success
					//
				} else if(element == "event")
				{
					//
					// Push the event to our data provider
					//
					var obj:Object = new Object();
					obj.id = nextId++;
					obj.eventName = xml.@name;
					obj.timestamp = xml.property.@value;
					_messages.push(obj);
				}
				trace("got it");
			}
				
//
//Is not invoqued as the socket connects but fails on the server arguments error.
//
			private function register(eventName:String):void
			{
				trace("Registers");
				var request:String = "<register event=\"" + eventName + "\"/>\n";			
				_socket.send(request);	
			}

			
			private function connectionHanlder (event:Event):void
			{
				trace("connected");
				_connected = true;	
				sendMessage();
			}
			
			private function IOHandler (event:IOErrorEvent):void
			{
				Alert.show(event.text,event.errorID.toString());
			}
			
			private function secureHandler (event:SecurityErrorEvent):void
			{
				Alert.show(event.text,event.errorID.toString());	
			}
			
			private function sendMessage():void
			{
				trace("Send");
				_socket.send({obj:body.text});
				body.text = "";
			}



Console writes

false
connected
Send
Send



here is the coldfusion error log

9-Feb-2009		 11:42 PM		 Error		 Thread-14		   
Cannot send outgoing message. OriginatorID '20128155' is not a valid socket id.
8-Feb-2009   	8:10 AM   	Information   	web-0   	 
C:\ColdFusion8\logs\socket-gateway.log initialized 



This use the default main.cfc of the coldfusion standard event gateway C:\ColdFusion8\gateway\cfc\examples\menu\main.cfc

thanks a lot.

Is This A Good Question/Topic? 0
  • +

Replies To: XMLSocket Gateway event subscription.

#2 CR250  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 58
  • Joined: 14-June 08

Re: XMLSocket Gateway event subscription.

Posted 06 March 2009 - 07:56 AM

Did you ever get anywhere with this?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1