Hello,
I'm working on a chat application that until this point was public( whole room took part in the conversation ). But right now, I need to add a feature with Private chat, automatically established.
Something like: http://labs.adobe.com/technologies/stratus/samples/
I did manage to do a private chat app based on the examples found in the LCCS SDK, but it seems a bit to much( from what LCCS accustomed me with ).
Can someone point me in a good direction to be able to connect 2 users in a room into a private chat, without them having to click one another?
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
LCCS provides private messaging using recipientID or recipientIDs property in MessageItem. So, if you want to send any private message on a message Item, you need to set any of these properties depending on whether you want to send to one user or a selected group of users. Here recipientID or recipientIDs refer to the userIDs of users.
Now, coming back to your chat , I am not sure whether you are using our SimpleChat pod component or you are using our SimpleChatModel component and building your own UI on top.
If you are directly using our pod component, then you can select the user to send private message.
And if you are using our model component, then you need to provide a ChatDescriptor to the sendMessage function and provide the recipient property inside ChatDescriptor as the userID of the user you want to send private messages. You can look into the sendMessage function inside SimpleChatModel and you will be more clear. We actually assign the recipient property of ChatDescriptor to the recipientID of the messageItem before sending it over network. You might need to override /tweak these functions
I agree we don't directly expose an API in Chat where you can provide recipientIDs and it will automatically do everything else, but our greater aim for the framework is to stress more on the basic component architecture rather than providing a standard high level components. Please let me know if I am missing anything.
Hope this helps
Thanks
Hironmay Basu
Views
Replies
Total Likes
Hi,
LCCS provides private messaging using recipientID or recipientIDs property in MessageItem. So, if you want to send any private message on a message Item, you need to set any of these properties depending on whether you want to send to one user or a selected group of users. Here recipientID or recipientIDs refer to the userIDs of users.
Now, coming back to your chat , I am not sure whether you are using our SimpleChat pod component or you are using our SimpleChatModel component and building your own UI on top.
If you are directly using our pod component, then you can select the user to send private message.
And if you are using our model component, then you need to provide a ChatDescriptor to the sendMessage function and provide the recipient property inside ChatDescriptor as the userID of the user you want to send private messages. You can look into the sendMessage function inside SimpleChatModel and you will be more clear. We actually assign the recipient property of ChatDescriptor to the recipientID of the messageItem before sending it over network. You might need to override /tweak these functions
I agree we don't directly expose an API in Chat where you can provide recipientIDs and it will automatically do everything else, but our greater aim for the framework is to stress more on the basic component architecture rather than providing a standard high level components. Please let me know if I am missing anything.
Hope this helps
Thanks
Hironmay Basu
Views
Replies
Total Likes
Hi Hironmay and thanks for answering.
Ok, I understand I think. Also, you mentioned only chat, so I guess the others: audio, video are done trough the publish function, and I assign the recipient in there like: audioPub.publish( $recipient_id ) or webcamPub.publish( $recipient_id ).
Well, I guess I'll just do some simple coding with my backend, nothing big.
Thanks again for the answers.
Views
Replies
Total Likes
Hi,
Everything is done through the recipientID and recipientIDs property of MessageItem. And everything inside LCCS that is passed over the network ultimately is a MessagItem.
So, if you look inside the PrivateStreamTest example under sampleApps that does private audio/video streaming, you will see we assign the recipientIDs. Only difference is that in AudioPublisher and WebcamPublisher, we expose the recipientIDs property which you can set directly so that you don’t need to fiddle with low level recipientID and recipientIDs property under MessageItem in StreamManager.
However, for chat, we don’t expose any such property directly and you will have to specify it through ChatMessageDescriptor or directly override functions in SimpleChatModel.
Hope this helps
Thanks
Hironmay Basu
Thank you for all the answers, everything is clear
Views
Replies
Total Likes
Hello again,
Short version:
I use submitChat() to send my id to the other guy, the other guy publishes his stream to me (that id). After that, the video/audio 2-way streaming works, but submitChat() doesn't trigger any event on the other side.
Long version:
I managed to make the video and audio private without a problem. But i'm experiencing some problems with chat
I don't really know if the flow is recomended, or even if it should happen like this:
This is what I need: 2 guys, enter a room, and are connected automaticaly (only with the help of a backend server) and can talk, etc.
Peer1 and Peer2 both connect to the LCCS room. They get their lccs user id, and send it my server.
From there, Peer2 is just sitting tightly. Peer1 is given the lccs user id from Peer2 and begins publishing to him.
Now, for Peer2 to actualy start publishing to Peer1, he needs to know his lccs user id. And, I figure well, why don't I send a private message to him, with the lccs room id, but "hidden".
The actual code is this:
protected function buildModel():void {
chatModel = new SimpleChatModel();
chatModel.sharedID = "myChat_SimpleChatModel";
chatModel.subscribe();
chatModel.addEventListener(ChatEvent.HISTORY_CHANGE, onChatMsg);}
protected function registrationSuccess():void {
var peer2_lccs_room_id = get_room_id();
submitChat("(cmd:)"+mylccsid);
}
protected function submitChat(str:String):void {
var cmd:ChatMessageDescriptor = new ChatMessageDescriptor();
cmd.msg = str;
cmd.recipient = conversation.lcid;
debug.text += "\n client msg: " + cmd.msg;
debug.text += "\n client recipient: " + cmd.recipient;debug.text += "\n sync: "+chatModel.isSynchronized; #this is true always
chatModel.sendMessage(cmd);
chat_input.text = ""; #this does really empty the input
}protected function onChatMsg(p_evt:ChatEvent):void {
debug.text += "\n lcid: " + conversation.lcid;
debug.text += "\n incoming text: ";
debug.text += "\n "+p_evt.message.msg;
if(p_evt.message != null && p_evt.message.msg != null) {
if( p_evt.message.msg.match(/(com:)/) ) {
var msg:String = p_evt.message.msg;
msg = msg.replace("(com:)", "");
conversation.lcid = msg;
publish();
}
else {
chat_area.text += "\n" + p_evt.message.displayName + ": " + p_evt.message.msg;
}
}
else {
chat_area.text = "";
}
}
This works nicely and enables me to make Peer2 start private publishing for Peer1.
The problem i'm confronting with is that, after that first message with "mylccsid", whenever I type something normaly, basicaly submitChat("some string"); it dosen't send the message.
Is this the only to do this? Or is there another simpler ( from API ) way to know then Peer1 is publishing to Peer2. (As an idea, in Stratus there was a controllNetStream responsible for that )
Sorry for wall of text
Views
Replies
Total Likes
Hi,
I am not sure why it won't submit the chat for you. You would need to link to the source and do debugging and see whether inside the ChatModel on the sender side , you are publishing the chatitem or not. And on the receiver side in itemReceive handler inside SimpleChatModel, you need to see whether you are getting the message or not.
Now , coming back to the approach, I personally don't think sending userID as part of chat message is a clean way to do things. For any such communication of userIDs( not necessarily just for a chat case but anything),
You can have a collectionNode set up where accessModel is 100 and publishModel is 10, which you can use as a channel for communication between any clients and your developer server.
On that collectionnode you should send that you want to private chat with user X,Y and your dev server should send the those users your id and then you can get going.
Regarding this specific case, try debugging and if it still doesn't work, make a small example and send it over. I can take a look
Thanks
Hironmay Basu
Views
Replies
Total Likes