6 Replies Latest reply: Mar 9, 2011 6:21 AM by shooding2011 RSS

    How to send message to direct connected users

    Ram_Nishad

      Hi,

       

      I am working on a text Chat application with FMS4 "RTMFP" connection and i am looking a functionality to send direct message to one to another peer, please some one help me.

       

       

      Thanks

      Sushil

        • 2. Re: How to send message to direct connected users
          Ram_Nishad Community Member

          Hi,

           

           

          thanks very much,

           

          i have gone through that link, but my requirement is not exactly same but similar  to that.

           

          suppose within group 10 member are connected and you are looking send message to 5 no. member then how will you send to him.

           

          Thanks
          Sushil

          • 3. Re: How to send message to direct connected users
            Amit Kumar Adobe Employee

            Below are the lines from above link which you can use for your purpose if your users are directly connected.

             

            Sending Message

            // peer2ID is of #2 (Moscow)
             
            var message:Object = new Object();
            message.destination = netGroup.convertPeerIDToGroupAddress(peer2ID);
            message.value = "Hello I am message from #1";
             
            netGroup.sendToNearest(msg, msg.dest);

            Receiving Message
            When you receive a Direct Routing message, it comes to NetStatusEvent with code “NetGroup.SendTo.Notify”:

            netGroup.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
             
            function netStatus(event:NetStatusEvent):void{
                 switch(e.info.code){
                 case "NetGroup.SendTo.Notify":
                      // e.info.message contains our message Object
                      trace("Received Message: "+e.info.message.value);
                      break;
                 }
            }

            But this will work only if #2 is a neigbor of #1.

            So if it is not directly connected use forwarding.

             

            Regards,

            Amit

            • 4. Re: How to send message to direct connected users
              shooding2011 Community Member

              Hi! I've checked out the document and trying to use

              groupAddr = convertPeerIDToGroupAddress("somePeerID");
              trace(groupAddr);

              But i got nothing from the function.
              My GroupSpecifier is set to:
              spec.serverChannelEnabled = true;
              spec.objectReplicationEnabled = true;
              spec.routingEnabled = true;
              spec.postingEnabled = true;

              Please help! Thanks!
              • 5. Re: How to send message to direct connected users
                Ram_Nishad Community Member


                sendBtn.addEventListener(MouseEvent.MOUSE_DOWN, sendMessage);

                 

                private function sendMessage():void
                {
                    var message:Object = new Object();
                    message.sendTo = peerID;
                    message.msg = 'how are you';
                    netGroup.post(message);
                }

                 


                When you will send message then it will dispatch a event "NetGroup.Posting.Notify" and this event will listen by every connected peer and peer side you will match peerID.

                 

                public function netStatusHandler(evt:NetStatusEvent):void
                {
                    switch(evt.info.code)
                    {
                        case 'NetGroup.Posting.Notify':
                            receiveMessage(evt.info.message);
                        break;
                    }   
                }

                 

                private function receiveMessage(msgObj:Object):void
                {
                    if(msgObj.sendTo==nc.neerId)
                    {
                        textBox.text +=msgObj.msg;
                    }
                }

                • 6. Re: How to send message to direct connected users
                  shooding2011 Community Member

                  Thanks for your reply.

                  But this way it will send messages to all peers and create certain control overheads.

                   

                  I was trying to send message to a specific peer, say from #1 to #3 via #2 (who is the nearest neighbor of #3 for instance)