Just wondered, but can you do a socket.connect across from a swf file in one domain to a server in another?
I would have thought the server would have to be on the same domain as the swf.
If you're having trouble, it might be worth trying the method within the domain before trying it across domains.
Morgan.
EDIT: Yep - Just checked the documentation, and cross-domain communication isn't allowed. Is your swf on the same domain as the server?
Last edited by ForumNewbie; 09-03-2006 at 05:24 PM.
server = new XMLSocket
bob = server.connect(null,2727)
I would expect if the XML socket server service was not running, bob would return a value of false, and if it the service was running it would return true.
However, it always returns a value of true, even if I stop the XML socket service. Why would that be? Any ideas?
If XMLSocket.connect() returns a value of true, the initial stage of the connection process is
successful; later, the XMLSocket.onConnect method is invoked to determine whether the final
connection succeeded or failed. If XMLSocket.connect() returns false, a connection could not
be established.
which suggests that the connect will verify the server while the OnConnect will verify the port.
I was struggling to get to grips with this, so I went back to first principles and used other people's examples to get something working first. Once I'd proved the principle, I decided I'd try and work it out myself....
If it helps anyone else, this is my progress to date :
Managed to use the XML Socket Server software mentioned above to set up an XML Socket Server. (www.morgan-multinational.com on port 2727)
Then tried to use 3DFA to connect to the server. Not a lot of luck there.
Started again using the prebuilt swf files that come with the XML socket server to connect to it, in order to prove it was working. Worked when running locally, but not remotely.
Had to work out tons of firewall settings regarding connectivity, but I now have a working XML socket server to play with.
The next step is to take the prebuilt swf file, and work out how to port it into 3dfa.
Here is the prebuilt swf file that I'm aiming to reproduce via 3dfa, so I can then start to do my own other applications:
EDIT: URL Removed because the later version is better, and the earlier versions are consuming all the user ID's on the server.
If anyone wants to play on this, go to this url, and enter the server 'www.morgan-multinational.com' in the host box, and you should be able to make a connection, and send messages to any of the other 5 people in the room.
Tomorrow's entertainment is trying to find a way to port the swf to 3dfa.
Fingers crossed.
Morgan.
Last edited by ForumNewbie; 09-10-2006 at 07:37 PM.
Try this: EDIT: URL Removed because the later version is better
This swf generated from 3dfa allows you to send a message from one window to another using an XML socket connection. I sent a message from one session to another, then replied back to the first. It works, although it's not very user friendly at the moment !
To prove it works, open 2 windows to the url above. One is going to be called client3 and the other client4.
Change the login name of one of them from Client3 to Client4 by altering the xml statement that appears in the send box.
Then connect with both windows by hitting the connect button.
You should get 'True' next to both connect boxes. This shows it can see the server, and connect to the port.
Click the 'send' button in each window to send the logon script to the server.
A response should come back to say 'error=0' next to the connect button. This shows it logged on to the server OK.
Then, paste this into the 'send' box from the session you called client 4 and hit the send button:
<protocol><userMsg sendTo="client3"><data game="Can you read this"></data></userMsg></protocol>
The message will appear in the editbox next to the connect button in the session you called client 3.
Then paste this into the send box in the window connected as client 3:
<protocol><userMsg sendTo="client4"><data game="Yes I got it thanks"></data></userMsg></protocol>
When you hit send, the message will appear in the editbox next to the connect button for client 4.
Just got to find a way to do something useful with it now !
M.
Last edited by ForumNewbie; 09-10-2006 at 07:35 PM.
A little progress made today, but not a lot. Here is a slightly more user friendly front-end: EDIT: URL Removed because the later version is better.
So, you can now select on the left hand side what user ID you want to connect as. Then click connect. You should get 'error code=0' to show you've connected correctly to the socket server. If you get error code of 12, choose another user ID, because that one is in use.
Then type a message, select who to send it to from the list on the right, and click 'Send'. If the user is logged in, you'll get an error code of 0. If not, then error of 32. If you send the message to your own user ID, the XML message it appears in will appear in the top one of the two boxes at the foot of the screen.
I think the next step will be to try and interpret the XML responses better, before trying to pass the x and y parameters of the cursor between 2 session, for a true interactive demo.
Hoping to have something more interesting for you soon !
M.
Last edited by ForumNewbie; 09-10-2006 at 07:34 PM.
It's getting there, though the movie needs a lot of commenting before I post it.
Here's the latest version: EDIT: URL Removed because the later version is much better. See below.
If you enter a User ID of Client1, 2, 3, 4 or 5, then you can post messages to anyone else in the room. Try opening up 2 windows to the same URL, connecting 1 as Client1 and the other as Client2, and we have a working chatroom.
I've got to enter some other error correction things, and a 'disconnect' message, and a list of other users in the room already, but otherwise, it's working pretty well.
Comments welcomed.
Morgan.
Last edited by ForumNewbie; 09-15-2006 at 03:26 PM.
It's absolutely really connected. Get 2 people to connect on 2 different machines, and it'll prove itself
Unfortunately, I messed it up when commenting it, so I'm having to fix that before posting the source code.
Sorry bout that
EDIT: Aaaaaaaaaaaaaarrrrrrrrrrrrrghhhhhhhhhhhhhhhhh. I'm sure it worked well on Wednesday when I finished playing with it. All I did today was comment it and clean up some of the script, and now it's completely dead ! I hate computers !
EDIT: OK. I have it working again from a previous version, and will have to comment the script again another day.
Source files re-commented and re-attached. Remember though, you'll need to set up an XML socket server first. This movie uses all the syntax required for eClever dmm, but the principle is probably the same for most XML socket servers.
It seems to list software for socket servers, and potential hosting companies.
The syntax used on each XML socket server is likely to be different to the one I used, but I'm sure the principle is the same. I think I might move to one of the free java based ones at some stage so I can have more users than the 5 ones I get with the package I'm using at the moment.