13 Replies Latest reply on Aug 23, 2007 7:52 AM by FlexIsGood4U

    chat client in flex

    SonOfChaos
      Is it possible to make IRC chat client using either flash or flex ? Are there any tutorials? What are performances of flex (or flash) client, compared to java applet IRC clients?

      thank you.
        • 1. Re: chat client in flex
          peterent Level 2
          Check out Flex Data Services/Messaging as well as Flash Media Server. Obviously my answer would be a little biased since I think it would be easier to develop such a thing in Flex (and I have using Flash Media Server). Perhaps others can share their own experiences.
          • 2. chat client in flex
            SonOfChaos Level 1
            thanks for your replay, but you haven't really answered any of my questions: can it be done and how?

            so, how to make browser IRC client using flex or flash? Any general tutorial on networking, using sockets and all?
            and by the way are there any significant differences in performance between as 2.0 and as 3.0 in networking?
            • 3. Re: chat client in flex
              peterent Level 2
              The answer is going to be complex for any solution unless you can find an off-the-shelf chat client. I know that we supply an example with Flex Data Services (you can download a free trial and check it out).

              The performance issue is also complex. We've done a lot with performance improvements. Chat applications require constant connections and for that we use RTMP. I suggest you go to the Flex or Flash Media Server documentation and read up on that. We probably have some white papers on it at our site.
              • 4. chat client in flex
                SonOfChaos Level 1
                RTMP is fine, but for this project I would really prefer to use standard IRC protocol , because I need to use other IRC clients (like mIRC) on the site, too, so I have to use IRC server, not flash media server.
                can it be done? I am pretty good in flash, AS 2.0, but I am not an expert. I'll check stuff at the site. I am still not very good at networking in flash, so I don't know if it is possible to make custom protocol using actionscript.

                thank you, and sorry for my bad English and noob questions.
                • 5. Re: chat client in flex
                  babo_ya Level 3
                  I know you could use Socket connection in Flash. We were deciding whether to develop something like this but, we decided just buy a copy $6G which does more than what we expected. And it looks like the application is developed using Flash and some type of Socket connections.(Don't know alot about server so...)



                  • 6. Re: chat client in flex
                    ManMachine
                    Hi,

                    It is possible to open a Socket connection and read and write anything from text to bytes through it. This means that you can write your own implementation of the IRC protocol (and any other protocol for that matter). Since IRC servers use ports above 1024, sandbox restrictions should be no problem.

                    /Johan
                    http://www.man-machine.se
                    • 7. chat client in flex
                      SonOfChaos Level 1
                      alright , I am using XMLsocket class, actrionscript 2.0 (flash 8). I have set up appache server on port 1024, and I can connect without problems. But something's wrong with sending test data (I am using log file to check for incoming server requests) the code is this:

                      quote:


                      var theSocket:XMLSocket = new XMLSocket();

                      theSocket.connect("localhost", 1024);

                      theSocket.onConnect = function(myStatus) {
                      if (myStatus) {
                      TraceTxt("connection successful");
                      } else {
                      TraceTxt("no connection made");
                      }
                      };

                      theSocket.onClose = function () {
                      trace("Connection to server lost.");
                      }

                      function sendData() {
                      var myXML:XML = new XML();
                      var mySend = myXML.createElement("thenode");
                      mySend.attributes.myData = "someData";
                      myXML.appendChild(mySend);

                      theSocket.send(myXML);
                      TraceTxt("I am trying to send: " + myXML);

                      }

                      sendButton.onRelease = function() {
                      sendData();
                      };

                      theSocket.onData = function(msg:String):Void {
                      trace(msg);
                      };

                      function TraceTxt(strMessage:String)
                      {
                      dtxMessage.text = dtxMessage.text + strMessage + "\n";
                      }



                      • 8. Re: chat client in flex
                        peterent Level 2
                        Try appending a null byte (or send a null byte after you've sent your message).
                        • 9. chat client in flex
                          SonOfChaos Level 1
                          how to send custom byte (or any other non-xml text) using XMLsocket.send() ? I tried looking in flash help, but there is no example or anything like that there.

                          Can it be done somehow like this:

                          XMLsocket("somethingHere");

                          thank you.
                          • 10. Re: chat client in flex
                            peterent Level 2
                            From the Flex documentation on XMLSocket:
                            XMLSocket class
                            ActionScript provides a built-in XMLSocket class, which lets you open a continuous connection with a server. This open connection removes latency issues and is commonly used for real-time applications such as chat applications or multiplayer games. A traditional HTTP-based chat solution frequently polls the server and downloads new messages using an HTTP request. In contrast, an XMLSocket chat solution maintains an open connection to the server, which lets the server immediately send incoming messages without a request from the client.

                            To create a socket connection, you must create a server-side application to wait for the socket connection request and send a response to the SWF file. This type of server-side application can be written in a programming language such as Java, Python, or Perl. To use the XMLSocket class, the server computer must run a daemon that understands the protocol used by the XMLSocket class. The protocol is described in the following list:

                            XML messages are sent over a full-duplex TCP/IP stream socket connection.
                            Each XML message is a complete XML document, terminated by a zero (0) byte.
                            An unlimited number of XML messages can be sent and received over a single XMLSocket connection.

                            According to the XMLSocket documentation, the send() method is supposed to send a zero-byte on its own. But to send one yourself:

                            socket.send(0);

                            should work.
                            • 11. Re: chat client in flex
                              SonOfChaos Level 1
                              well, thanks for everything, but it doesn't help

                              And when I send the exact same thing using command prompt telnet, it works ok, and request is noted in a log. But apache doesn't leave any mark when I try to send something to it using flash. I even used ethereal to find a packet, and I found it, but server is still mute.
                              • 12. chat client in flex
                                SonOfChaos Level 1
                                Ok, now it works somewhat. The problem was with my query. Valid request should look like this:

                                theSocket.send("GET /HTTP/ 1.1\n\n");

                                (note the two "\n" at the end)

                                Now, the problem is that I can't receive data from server. Server just automatically disconnects, with no data sent for some reason. And don't forget I am talking about actionscript 2.0 here.

                                what's wrong?
                                • 13. Re: chat client in flex
                                  FlexIsGood4U
                                  So as to avoid doubloons in the forum, I will ask my question.

                                  I would like to add a Flex chat client on a PHP website (not respecting IRC or others standards... I do not care about this).

                                  As I will not manage Flex Data Services on my server, my problem is to define how real-time communications from PHP server to Flex clients (or at least pull data as a consumer).

                                  I could not find any documentation with Googling. Any ideas ?