just starting, need help - 2006/10/01 00:44ok, here is my code so far, I can connect to the server and make a room:
Code:
onFrame (5) {
var sample_socket:XMLSocket = new XMLSocket();
sample_socket.connect('localhost', 2468);
sample_socket.onConnect = function(status) {
if (status) {
_root.sample_socket.send('<connect nickname="test_'+random(30)+'" ></connect>');
_root.sample_socket.send('<join room="test" />');
conn_txt.text = "yes connection successful";
stop();
} else {
conn_txt.text = "no connection made";
}
};
}
but now I want to do something noticable. I want the other client to see something I do with the first client. Just to make sure its working. However, I don't know how. Can you help me send something to the server that will show up on all clients windows, like a text string or a box moving, thanks.
Btw, I am loving this program so far, good job making it.
I didn't make the button yet because I wanted to test it this way first. However, the return says only "[type Function]" (without the ""). I know it must have gotten that from the server because it returns nothing when the server isn't on. I am trying to solve the problem, but I thought I would offer this to you incase you have seen it before and can offer a quick answer :)
Re:just starting, need help - 2006/10/02 21:53ok, I just want to tell you that I am not using macromedia flash. Im using a cheaper program called swish. So far everything has been working. However, it says the code has an error if I don't put an ";" after onXML(xml). And the program wont run anything if it thinks there is an error. Anyway, perhaps having the ";" is messing up this code because it still returns [type Function].
Re:just starting, need help - 2006/10/03 00:01Ok, a roomate (math major) helped me with my code. He reorganized alot of it and here it is:
Code:
function myOnXML(doc) {
var e = doc.firstChild;
Warning.text = "I made it here, where is the XML node that should have been returned from the server!";
receive.text = e.nodename;
//if (e != null && e.nodeName == "MESSAGE") {
//displayMessage(e.attributes.user, e.attributes.text);
//receive.text = e.attributes.text;
//}
}
onFrame (1)
{
msgxml = new XML('<dummymsg toroom="test">Super duper message </dummymsg>');
x_socket = new XMLSocket();
x_socket.onXML = myOnXML;
x_socket.onClose = showWarning;
if (x_socket.connect('localhost', 2468))
{
x_socket.send('<connect nickname="test_'+random(30)+'" ></connect>');
x_socket.send('<join room="test" />');
if(x_socket.send('<msg toroom="test">Super message </msg>'))
{
receive.text = "Sent message.";
};
conn_txt.text = "yes connection successful";
//stop();
}
}
Anyway, The good news is that it deffinatly sends information to the server. In fact, your demo client recieves the message from our client perfectly. However, for some reason our script doesnt recieve the message. Any idea why?
Re:just starting, need help - 2006/10/03 09:07Hum, the code is good Obviously Swich does not support the same syntax as Flash, but with your code the result is the same.
The first part of the problem is that by default, messages sent to a room are not coming back to sender to avoid useless traffic, if you want it back just send : <msg toroom="test" back="1">Message ! </msg>
The other problem, "Might" be that you are sending three informations without waiting.
As all thoose "sends" are asynchronous and are happening in the same millisecond, you should wait to be connected to the server before sending the 'connect' node, then you should wait for the "<connect isok=1 />" node before joining a room and you should wait to be in the room before sending a message.
so the code might be :
Code:
function myOnXML(doc) {
var e = doc.firstChild;
Warning.text = "I made it here, where is the XML node that should have been returned from the server!";
receive.text = e.nodename;
if(e.nodeName == 'connect' ) {
x_socket.send('<join room="test" />');
} else if(e.nodeName == 'joined' ) {
x_socket.send('<msg toroom="test" back="1">This is a test message </msg>');
}
}
function myOnConnect(result) {
if(result) {
Warning.text += 'connection ok';
x_socket.send('<connect nickname="test_'+random(30)+'" ></connect>');
} else {
Warning.text += 'connection failed';
}
}
onFrame (1)
{
x_socket = new XMLSocket();
x_socket.onXML = myOnXML;
x_socket.onClose = showWarning;
x_socket.onConnect = myOnConnect;
x_socket.connect('localhost', 2468);
}
Hope i'm helping :)
Have fun !Célio Conort Lonesome Palabre developper
Re:just starting, need help - 2006/10/04 14:14thankyou for all your help. I really appreciate it! but i think the problem must be swish. It looks like I will have to buy flash one of these days, expencive hobby but maybe its worth it. :)