Hi all,
in most cases my SocketServer-class is sending and receiving messages without any problems.
But espacially if the Socket is receiving messages (onXML) and has to send outgoing messages "at the same time" this will fail from time to time...
Does anybody have an idea?
a++
André
###############
The class:
###############
import mx.events.EventDispatcher;
import mx.utils.Delegate;
[Event("connectionSucceeded")]
[Event("connectionFailed")]
[Event("connectionClosed")]
[Event("messageReceived")]
[Event("debugMessage")]
class SocketServer
{
public var addEventListener:Function;
public var removeEventListener:Function;
private var dispatchEvent:Function;
private var _socket:XMLSocket = null;
private var _server:String;
private var _port:Number;
public function SocketServer()
{
_socket = new XMLSocket();
EventDispatcher.initialize(this);
_socket. OnConnect);
_socket. OnClose);
_socket. OnXML);
}
public function connectToServer(IPAddress:String, Port:Number) :Void
{
_server = IPAddress;
_port = Port;
_socket.connect(_server, _port);
}
public function close() :Void
{
_socket.close();
}
private function OnConnect(success :Boolean) :Void
{
if (success)
dispatchEvent({type: "connectionSucceeded"});
else
dispatchEvent({type: "connectionFailed"});
}
private function OnXML(message :XML) :Void
{
dispatchEvent({type: "messageReceived", message: message});
dispatchEvent({type:"debugMessage", message:message, direction:"receive"});
}
public function send(message:String):Void
{
dispatchEvent({type:"debugMessage", message:message, direction:"send"});
_socket.send(message);
}
private function OnClose() :Void
{
dispatchEvent({type: "connectionClosed"});
}
}
################
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

