Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

One-One Chat Application using LCCS

Avatar

Former Community Member

Hi,

   I want to create a chat application that allow users to select a particular user from the room and chat with that person alone.I tried and succeeded in creating a chat application that works like a group chat, where all the users in the room can see all the messsges.Is there anything to do in room console with permissions,pls explain..

Thanks in advance!!!

1 Accepted Solution

Avatar

Correct answer by
Level 3

Yep. It's basically the same idea but actually a bit easier. The code should be something like this...

Cam:

        private function startPublisher() : void {

// Removing the recipient ids on the publishing side. Everything should be handled ok by setting publisher ids on the receiving side for each receiver

//          var recipientIDs:Array = new Array();

//          var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);

//          recipientIDs.push(userId);

//          webcamPub.recipientIDs = recipientIDs;

            if(webcamPub.isPublishing == false) {

                webcamPub.quality = 85;

                webcamPub.keyframeInterval = 36;

                webcamPub.publish();

            }

        }

        private function startSubscriber() : void {
           
            // For now I am going to user publisherIds on the subscribing side     
            var publisherIDs:Array = new Array();
            var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);
            publisherIDs.push(userId);
            webcamSub.publisherIDs = publisherIDs;
           
            webcamSub.subscribe();                       
        }
Audio:
        // Start the audio publisher
        private function startPublisher() : void {
            var recipientIDs:Array = new Array();
           
            var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);
            recipientIDs.push(userId);
           
            try {
                audioPub.recipientIDs = recipientIDs;
                audioPub.publish();        
            }
            catch(err:Error) {
                Logger.getInstance().info("Caught an Exception trying to publish the audio stream. Continue on.");
            }
           
        }
        private function startSubscriber() : void {
           
            var publisherIDs:Array = new Array();
            var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);
            publisherIDs.push(userId);
            audioSub.publisherIDs = publisherIDs;
           
            try {
               
                audioSub.subscribe();              
            }
            catch(err:Error) {
                Logger.getInstance().info("Caught an Exception trying to subscibe to the audio stream. Will try again.");
               
            }
        }
This is just skeleton code and you will have to write some routines to clean up resources if you want to stop/start the cam/audio. This should be enough to set you in the right direction.
Barry

View solution in original post

6 Replies

Avatar

Level 4

I'd recommend reading through to give you an idea of structure and details of LCCS:

* http://learn.adobe.com/wiki/display/lccs/LiveCycle+Collaboration+Service

For example, one of the chapters is on Audio/Video streams:

* http://learn.adobe.com/wiki/display/lccs/08+Audio%2C+WebCam%2C+and+Screen+Sharing

Quoting from the document:

I don't know if there's a way to do permission and userID filtering on A/V streams in the room console, but you should be able to in AS3/Flex fairly easy. The example in the  LCCS SDK "sampleApps/Audio/Audio.mxml" will probably help you get started. For example:

            /****
             * When published stream is received, start polling the activity level of my microphone.
             */
            private function onStreamReceive(p_evt:StreamEvent):void
            {
                if ( p_evt.streamDescriptor.finishPublishing && p_evt.streamDescriptor.streamPublisherID == cSession.userManager.myUserID) {
                ..................
                }
            }

I haven't done this myself, so feel free to correct me

Alex G.

Avatar

Level 4

Hey,

In your app you need to know what the user ID is. Everyone who connects to the room is assigned an ID by the service.

If you know what the ID is you can send a private message. (make sure the node details have allowPrivateMessages checked off)

Then you can send a message just like a public chat but make sure that there is a receipient with the right id.

Here is how I've been doing it.

var messItem:MessageItem = new MessageItem("PrivateMessage");

    messItem.publisherID =  this.MyID

    messItem.recipientID = userID;

    messItem.collectionName = _msgCollection.sharedID;

    messItem.body = {

note: "closeWindow"

}

    _msgCollection.publishItem(messItem);

so your publishing to a node called private message.

try it out.

...russ

Avatar

Level 3

Here's some sample code that will help you to direct messages to individual clients:

public var chatModel:SimpleChatModel;

chatModel.allowPrivateChat = true;

var message:String = "Hello";

var cmd:ChatMessageDescriptor = new ChatMessageDescriptor();

cmd.displayName = session.userManager.getUserDescriptor(session.userManager.myUserID).displayName;

cmd.msg =  message;

var userId : String = getUserIdForDisplayName(session, targetUser);

cmd.recipient = userId;

chatModel.sendMessage(cmd);

// This will get you the userId for the target user from the users display name
public static function getUserIdForDisplayName(session : ConnectSessionContainer, displayName : String) : String
{
for(var i:int = 0; i < session.userManager.userCollection.length; i++) {
if((session.userManager.userCollection.getItemAt(i) as UserDescriptor).displayName == displayName)
return (session.userManager.userCollection.getItemAt(i) as UserDescriptor).userID;
}
return null;
}

Avatar

Former Community Member

Hey thank you so much i got it working.can the same approach be followed for audio and video chat too???

Avatar

Correct answer by
Level 3

Yep. It's basically the same idea but actually a bit easier. The code should be something like this...

Cam:

        private function startPublisher() : void {

// Removing the recipient ids on the publishing side. Everything should be handled ok by setting publisher ids on the receiving side for each receiver

//          var recipientIDs:Array = new Array();

//          var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);

//          recipientIDs.push(userId);

//          webcamPub.recipientIDs = recipientIDs;

            if(webcamPub.isPublishing == false) {

                webcamPub.quality = 85;

                webcamPub.keyframeInterval = 36;

                webcamPub.publish();

            }

        }

        private function startSubscriber() : void {
           
            // For now I am going to user publisherIds on the subscribing side     
            var publisherIDs:Array = new Array();
            var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);
            publisherIDs.push(userId);
            webcamSub.publisherIDs = publisherIDs;
           
            webcamSub.subscribe();                       
        }
Audio:
        // Start the audio publisher
        private function startPublisher() : void {
            var recipientIDs:Array = new Array();
           
            var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);
            recipientIDs.push(userId);
           
            try {
                audioPub.recipientIDs = recipientIDs;
                audioPub.publish();        
            }
            catch(err:Error) {
                Logger.getInstance().info("Caught an Exception trying to publish the audio stream. Continue on.");
            }
           
        }
        private function startSubscriber() : void {
           
            var publisherIDs:Array = new Array();
            var userId : String = Util.getUserIdForDisplayName(CocomoSession.session, this.currentTargetUser);
            publisherIDs.push(userId);
            audioSub.publisherIDs = publisherIDs;
           
            try {
               
                audioSub.subscribe();              
            }
            catch(err:Error) {
                Logger.getInstance().info("Caught an Exception trying to subscibe to the audio stream. Will try again.");
               
            }
        }
This is just skeleton code and you will have to write some routines to clean up resources if you want to stop/start the cam/audio. This should be enough to set you in the right direction.
Barry

Avatar

Former Community Member

Thank u very much.I will try and let you know...Thanks once again for the answers..

cheers,

Naveen M