Flash peer-to-peer video chat

Does anyone know if Flash peer-to-peer video chat is a possibility?--and if so, any source code to get me started.
John AccountAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John AccountAuthor Commented:
By the way, I'm asking as a developer--to develop an application utiliizing Flash Peer-To-Peer chat.
0
CyanBlueCommented:
I don't think it is possible to do the p2p with Flash...  You will need a server to connect two clients...

CyanBlue
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

teddysetiawanCommented:
FMS (Flash Media Serever ) will do the job , lots of sample about video chat using flash and FMS
If you want open source server try use Red5

here is what FMS can do , http://www.influxis.com/

its a web hosting ( FMS hosting ) with build in ready to use video  web chat .
( its just a sample what FMS can do )
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John AccountAuthor Commented:
I'm slightly confused as to your reply, Teddy. My question asks if I can do peer-to-peer video chat with Flash; you reply to use a server. Maybe there is something I don't understand...like, are you saying that, while using the FMS or Red5, I can set up the clients to do peer-to-peer video chat? And if that's the case, then why the hell must I use one of these servers?--merely to establish the connections? More info, please.
Many Kind Thanks,
John
0
CyanBlueCommented:
No, basically you cannot do the peer to peer if you are using Flash...  Teddy is just suggesting alternative that can do the video chat but that won't be peer to peer...

CyanBlue
0
John AccountAuthor Commented:
Well, that's too bad....sigh...and it's not that I don't doubt the word of either of you, but I'm going to leave this open a bit longer in hopes that you are wrong, and that there is a way to do peer-to-peer video chat with Flash. Thanks.
0
CyanBlueCommented:
Just out of curiosity, are you talking about the web app or a desktop app???

CyanBlue
0
John AccountAuthor Commented:
Web app
0
CyanBlueCommented:
You definitely have no way of doing the peer to peer if that is the case as far as I am aware of...
I was going to suggest looking up the third party projector tools such as Zinc or mProjector or create your own wrapper if it is for the desktop app...

CyanBlue
0
John AccountAuthor Commented:
hmmmmmmmmmnnn...how bout if it was for a desktop app--could that be Flash peer-to-peer?
0
CyanBlueCommented:
Um...  Please check line 2 of what I have posted earlier...  ;)

CyanBlue
0
teddysetiawanCommented:
Security is a big concern in flash ,Like Cyan said , you can't do P2P in flash ( as far as  know ).
In the next generation of flash (Apollo) , they added alot of things that might be able P2P  ( just don't have time to play for doing P2P thing)

you can read the article in here
http://www.onflex.org/ted/2006/10/web-20-is-distributed-internet.php

and here's the comment from Ted Patrick
"P2P in Apollo? Hmmmm....

Flash Player supports:
flash.net.Socket, AKA Binary Socket for 2 way data exchange of binary data.

Code here is hypothetical!!!

import apollo.net.Server
myServer:Server = new Server();
myServer.addEventListener( Server.CONNECT, connectHandler );
myServer.addEventListener( Server.DATA, dataHandler );
myServer.addEventListener( Server.DISCONNECT, disconnectHandler );
myServer.ports = [80,8080,1492,1976];
myServer.listen();

Technically its feasable. Security and Legal will be the barriers on this one.

Ted :) "


 


0
John AccountAuthor Commented:
I don't know which way I'm going to go at this point, but you both convinced me P2P via Flash is a no go. Previously, I"ve used the avphone activex from www.banasoft.net, but I can't make a wrapper for it to work with asp.net. Sigh.
0
teddysetiawanCommented:
Since the apollo have been release ( alpha ) a lot of thing may change in the security issue,
I'm not suprise if in the future flash/Apollo/Flex  will change the way user interact each other over the net.

AS 3.0 have socket class , and there are alot  sample how to use it , from SMTP,POP3, but have'nt seen any P2P sample.

But still the main issue is the security.

I've been asking your question to the flex/apollo comunity , I will share the knowledge in here

Regards


Teddy
0
John AccountAuthor Commented:
Thanks, Teddy. Your kindness and thoughtfulness is appreciated very much.
0
teddysetiawanCommented:
Sorry , I can't help you a lot with these , you should try and moving to AS 3.0 using flex/apollo
and try to build your own P2P app or you can wait until someone build it  ^_^.

I have ask around about this P2P thing , they all said it can be done , but there's no sample that I can give it to you, and still the main problem is the security thing.

In the mean time here's what I found
http://code.google.com/p/as3corelib/

lots of interesting classes in there including extended socket class.
remember this is AS 3.0 actionscript
before you jump in to try these class I suggest you learn AS 3.0 first and how to use it.


/*
      Adobe Systems Incorporated(r) Source Code License Agreement
      Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
      
      Please read this Source Code License Agreement carefully before using
      the source code.
      
      Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
      no-charge, royalty-free, irrevocable copyright license, to reproduce,
      prepare derivative works of, publicly display, publicly perform, and
      distribute this source code and such derivative works in source or
      object code form without any attribution requirements.  
      
      The name "Adobe Systems Incorporated" must not be used to endorse or promote products
      derived from the source code without prior written permission.
      
      You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
      against any loss, damage, claims or lawsuits, including attorney's
      fees that arise or result from your use or distribution of the source
      code.
      
      THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
      ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
      BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
      FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ALSO, THERE IS NO WARRANTY OF
      NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT.  IN NO EVENT SHALL MACROMEDIA
      OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
      EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
      PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
      OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
      WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
      ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.adobe.net.proxies
{
      import flash.events.Event;
      import flash.events.IOErrorEvent;
      import flash.events.ProgressEvent;
      import flash.net.Socket;

      /**
       * This class allows TCP socket connections through HTTP proxies in accordance with
       * RFC 2817:
       *
       * ftp://ftp.rfc-editor.org/in-notes/rfc2817.txt
       *
       * It can also be used to make direct connections to a destination, as well. If you
       * pass the host and port into the constructor, no proxy will be used. You can also
       * call connect, passing in the host and the port, and if you didn't set the proxy
       * info, a direct connection will be made. A proxy is only used after you have called
       * the setProxyInfo function.
       *
       * The connection to and negotiation with the proxy is completely hidden. All the
       * same events are thrown whether you are using a proxy or not, and the data you
       * receive from the target server will look exact as it would if you were connected
       * to it directly rather than through a proxy.
       *
       * @author Christian Cantrell
       *
       **/
      public class RFC2817Socket
            extends Socket
      {
            private var proxyHost:String = null;
            private var host:String = null;
            private var proxyPort:int = 0;
            private var port:int = 0;
            private var deferredEventHandlers:Object = new Object();
            private var buffer:String = new String();

            /**
             * Construct a new RFC2817Socket object. If you pass in the host and the port,
             * no proxy will be used. If you want to use a proxy, instantiate with no
             * arguments, call setProxyInfo, then call connect.
             **/
            public function RFC2817Socket(host:String = null, port:int = 0)
            {
                  if (host != null && port != 0)
                  {
                        super(host, port);
                  }
            }
            
            /**
             * Set the proxy host and port number. Your connection will only proxied if
             * this function has been called.
             **/
            public function setProxyInfo(host:String, port:int):void
            {
                  this.proxyHost = host;
                  this.proxyPort = port;

                  var deferredSocketDataHandler:Object = this.deferredEventHandlers[ProgressEvent.SOCKET_DATA];
                  var deferredConnectHandler:Object = this.deferredEventHandlers[Event.CONNECT];

                  if (deferredSocketDataHandler != null)
                  {
                        super.removeEventListener(ProgressEvent.SOCKET_DATA, deferredSocketDataHandler.listener, deferredSocketDataHandler.useCapture);
                  }

                  if (deferredConnectHandler != null)
                  {
                        super.removeEventListener(Event.CONNECT, deferredConnectHandler.listener, deferredConnectHandler.useCapture);
                  }
            }
            
            /**
             * Connect to the specified host over the specified port. If you want your
             * connection proxied, call the setProxyInfo function first.
             **/
            public override function connect(host:String, port:int):void
            {
                  if (this.proxyHost == null)
                  {
                        this.redirectConnectEvent();
                        this.redirectSocketDataEvent();
                        super.connect(host, port);
                  }
                  else
                  {
                        this.host = host;
                        this.port = port;
                        super.addEventListener(Event.CONNECT, this.onConnect);
                        super.addEventListener(ProgressEvent.SOCKET_DATA, this.onSocketData);
                        super.connect(this.proxyHost, this.proxyPort);
                  }
            }

            private function onConnect(event:Event):void
            {
                  this.writeUTFBytes("CONNECT "+this.host+":"+this.port+" HTTP/1.1\n\n");
                  this.flush();
                  this.redirectConnectEvent();
            }
            
            private function onSocketData(event:ProgressEvent):void
            {
                  while (this.bytesAvailable != 0)
                  {
                        this.buffer += this.readUTFBytes(1);
                        if (this.buffer.search(/\r?\n\r?\n$/) != -1)
                        {
                              this.checkResponse(event);
                              break;
                        }
                  }
            }
            
            private function checkResponse(event:ProgressEvent):void
            {
                  var responseCode:String = this.buffer.substr(this.buffer.indexOf(" ")+1, 3);

                  if (responseCode.search(/^2/) == -1)
                  {
                        var ioError:IOErrorEvent = new IOErrorEvent(IOErrorEvent.IO_ERROR);
                        ioError.text = "Error connecting to the proxy ["+this.proxyHost+"] on port ["+this.proxyPort+"]: " + this.buffer;
                        this.dispatchEvent(ioError);
                  }
                  else
                  {
                        this.redirectSocketDataEvent();
                        this.dispatchEvent(new Event(Event.CONNECT));
                        if (this.bytesAvailable > 0)
                        {
                              this.dispatchEvent(event);
                        }
                  }
                  this.buffer = null;
            }
            
            private function redirectConnectEvent():void
            {
                  super.removeEventListener(Event.CONNECT, onConnect);
                  var deferredEventHandler:Object = this.deferredEventHandlers[Event.CONNECT];
                  if (deferredEventHandler != null)
                  {
                        super.addEventListener(Event.CONNECT, deferredEventHandler.listener, deferredEventHandler.useCapture, deferredEventHandler.priority, deferredEventHandler.useWeakReference);                  
                  }
            }
            
            private function redirectSocketDataEvent():void
            {
                  super.removeEventListener(ProgressEvent.SOCKET_DATA, onSocketData);
                  var deferredEventHandler:Object = this.deferredEventHandlers[ProgressEvent.SOCKET_DATA];
                  if (deferredEventHandler != null)
                  {
                        super.addEventListener(ProgressEvent.SOCKET_DATA, deferredEventHandler.listener, deferredEventHandler.useCapture, deferredEventHandler.priority, deferredEventHandler.useWeakReference);                  
                  }
            }
            
            public override function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int=0.0, useWeakReference:Boolean=false):void
            {
                  if (type == Event.CONNECT || type == ProgressEvent.SOCKET_DATA)
                  {
                        this.deferredEventHandlers[type] = {listener:listener,useCapture:useCapture, priority:priority, useWeakReference:useWeakReference};
                  }
                  else
                  {
                        super.addEventListener(type, listener, useCapture, priority, useWeakReference);
                  }
            }
      }
}

0
John AccountAuthor Commented:
Wow, Teddy. Thanks! I think I'm going to move to AS 3.0 using flex/apollo, as you've suggested. The information you provided certainly sounds very promising.

Do you have a website?
0
CyanBlueCommented:
Interesting find, Teddy...  Something to investigate further...  Nice...  :)

CyanBlue
0
teddysetiawanCommented:
John,

Must understand that it will be completely different from AS 2.0, and especially who never or less doing coding in actrionscript, no frame , no timeline in flex/apollo.

For you who familiar with flash environment I believe Adobe CS 3.0 will be coming out around April, and you can pre order it right now.
One thing that amaze me is that you can convert your timeline animation into AS 3.0 in just single click.

I think its around $600 and $200 for upgrade.

btw sorry john , no website at the moment ,
you can contact me at teddysetiawan@ hotmail. com

or you can always ask in here , at the experts-exchange ,
as I believe more brain are better than one.


Cyan, it will be very  interesting if you can share your knowledge after your investigation  ;)
0
CyanBlueCommented:
Well...  Don't expect that to be happening any time soon cuz I am just trying to dive into that can of worms, uh I mean AS3...  But I'll get back to you if I ever can get this thing any further...  ;)

CyanBlue
0
yarekGmailCommented:
stratus can be used.

this is called RTMPF and popular sites wuch as: www.chatroulette.com (adn other clones www.visioroulette.com) do use it !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.