A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 46

Thread: Chat Room

  1. #21
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    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.
    Please note that my domain has changed to http://www.morganmultinational.com

  2. #22
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    There is a way if you have acess to the other server and put a crossdomain policy file where you specify what other domains can access.

  3. #23
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    OK. So this one's got me intrigued..... but I know I'm out of my depth....

    I set up an XML socket server using http://multiuser.web-cd.net/en/examples.aspx
    The service looks to be running on port 2727 on my webserver.

    My script is simply:

    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?

    Morgan
    Please note that my domain has changed to http://www.morganmultinational.com

  4. #24
    Senior Member
    Join Date
    May 2005
    Posts
    163
    According to the doc...

    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.

  5. #25
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590

    Making some progress....

    Well....

    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.
    Please note that my domain has changed to http://www.morganmultinational.com

  6. #26
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Well.... I got something to work in 3DFA....

    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.
    Please note that my domain has changed to http://www.morganmultinational.com

  7. #27
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    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.
    Please note that my domain has changed to http://www.morganmultinational.com

  8. #28
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    OK. Made it a bit more user friendly, but still having a bit of trouble with interpreting the XML.

    Here's a question:

    If I have a string containing: 'What&apos;s this' how do I convert this to the string 'What's this' ?

    Cheers,

    Morgan.
    Please note that my domain has changed to http://www.morganmultinational.com

  9. #29
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    OK.

    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.
    Please note that my domain has changed to http://www.morganmultinational.com

  10. #30
    Senior Member
    Join Date
    Apr 2004
    Location
    Los Angeles
    Posts
    198
    Hi Morgan,

    Your work is really interesting and I am monitoring your progress.

    Rick

  11. #31
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    Quote Originally Posted by ForumNewbie
    OK. Made it a bit more user friendly, but still having a bit of trouble with interpreting the XML.

    Here's a question:

    If I have a string containing: 'What&apos;s this' how do I convert this to the string 'What's this' ?

    Cheers,

    Morgan.
    The answer to this one was easier than I thought. I just had to change the setting on the Editbox I used to display the text to 'Format as HTML'.

    Hope this helps someone.

    The latest version is working pretty well now on http://www.morgan-multinational.com/..._socket_7.html but I need some visitors to test it The user ID you use must have more 5 or more characters.

    M.
    Last edited by ForumNewbie; 09-15-2006 at 03:28 PM.
    Please note that my domain has changed to http://www.morganmultinational.com

  12. #32
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    I'm grinding to a halt with this now, since I've had a busy week, so I thought I might as well post the source movie so far.

    I've commented most of the script, although it is all a bit ugly since it kind of evolved as I went along.

    Most of the scripting is to cater for the syntax that the XML socker server uses. The interactions themselves are a doddle.

    The latest version is available here: EDIT: URL REMOVED BECAUSE I SCREWED THAT VERSION UP SOMEHOW

    Hope this is of interest to someone

    Morgan.

    EDIT: Attachment temporarily removed as I messed it up when I commented it. Will revise and repost shortly.
    Last edited by ForumNewbie; 09-14-2006 at 06:31 PM.
    Please note that my domain has changed to http://www.morganmultinational.com

  13. #33
    Senior Member
    Join Date
    Apr 2004
    Location
    Los Angeles
    Posts
    198
    Nice - for sure / Is this really connected or is it a simulation?

    Rick
    Last edited by rblanc; 09-14-2006 at 06:09 PM.

  14. #34
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    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.

    Here's the link: http://www.morgan-multinational.com/..._socket_7.html

    Lots of bugs in it, but it works
    Last edited by ForumNewbie; 09-14-2006 at 06:30 PM.
    Please note that my domain has changed to http://www.morganmultinational.com

  15. #35
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    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.

    Hope this is of interest.

    M.
    Attached Files Attached Files
    Please note that my domain has changed to http://www.morganmultinational.com

  16. #36
    Senior Member
    Join Date
    Apr 2004
    Location
    Los Angeles
    Posts
    198
    Hi Morgan,

    Can you assist in how to setup a SS? Can the SS be hosted by a hosting company?

    Rick

  17. #37
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    I must admit, I didn't do much research before I picked a socket server for testing.

    I've just had a very quick look around, and this thread might be useful.
    http://www.flashmove.com/board/showt...4729#post94729

    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.

    Hope this helps.

    Morgan.
    Please note that my domain has changed to http://www.morganmultinational.com

  18. #38
    Senior Member
    Join Date
    Apr 2004
    Location
    Los Angeles
    Posts
    198
    Java? - Ouch!

    Morgan, you are already using XML/Javascript why not try to find a socket server based upon Ajax?

    Rick
    Last edited by rblanc; 09-15-2006 at 11:48 AM.

  19. #39
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    I think he's refering to java on the server not the client.

  20. #40
    A Senior Newbie - How Odd ForumNewbie's Avatar
    Join Date
    Mar 2003
    Posts
    590
    I am, but I know next to nothing about servers, so I've no idea how it all works

    If I learn anything useful, I'll try and share
    Please note that my domain has changed to http://www.morganmultinational.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center