socket.send("<?xml version=\"1.0\"?><msg message=\"happyness\" />" +
"\0");
don´t forget the null byte
perry
"crazygamer" <webforumsuser@macromedia.com> schrieb im Newsbeitrag
news:c8o1nq$gfn$1@forums.macromedia.com...
[quoted text, click to view] > I'm creating a new socket, connecting to it and recieving a message from
it
> (all with success), but when i try socket.send, nothing happens. The
socket
> server is set up to send back whatever I send it, and since I've already
> recieved stuff from it, i know the problem is with the sending. Does
anyone
> know what could be wrong with the socket.send . In the code, messages is a
> textarea. Code attached.
>
>
> //socket code
> _global.socket = new XMLSocket();
> socket.onConnect = function(success) {
> if(!success) {
> messages.text = "Unable to connect to server";
> }
> }
> socket.onClose = function() {
> messages.text += "Socket Closed";
> }
> socket.onXML = function(doc) {
> displayRecieved(doc);
> }
> socket.onData = function(doc) {
> displayRecieved(doc);
> }
> if(socket.connect("www.norcalmusic.net", 5555)) {
> socket.send("<?xml version=\"1.0\"?><msg message=\"happyness\" />");
> }
> //
> //buttons
> send.addEventListener("click", submit);
> reset.addEventListener("click", resetConn);
> //listeners
> _root.onKeyDown = function() {
> if (Key.getCode() == Key.ENTER) {
> if (input.text != "") {
> submit();
> }
> }
> }
> //functions
> function submit() {
> /*tosend = input.text;
> socket.send(tosend);
> input.text = "";*/
> socket.send("<?xml version=\"1.0\"?><msg message=\"happyness\" />");
> }
> function resetConn() {
> socket.close();
> socket.connect("www.norcalmusic.net", 5555);
> }
> function displayRecieved(doc) {
> var xmlData = new XML(doc);
> var node = xmlData.firstChild.nodeName;
> var atts = xmlData.firstChild.attributes;
> if(node == "welcome") {
> messages.text += atts.toprint;
> }
> else if(node == "msg") {
> messages.text += "\n"+atts.from+": "+atts.message;
> }
> messages.vPosition = messages.maxVPosition;
> }
>