[In-App Chat Mobile] In App Chat - How many Subject Ids should be created in One to One chat ?

[In-App Chat Mobile] In App Chat - How many Subject Ids should be created in One to One chat ?

  
Forge Component
(5)
Published on 2017-11-27 by Labs
5 votes
Published on 2017-11-27 by Labs

Hello Mates, 

I'm Implementing a mobile chat app by using the In-App-Chat Mobile module features, but I'm confused about the subject ID creation in a One to One chat. 

Should we create a subject for each Chat Creator or One Subject only is enough and they both should use the same Subject ID. Same subject ID is the answer I think. 

So If they will share the same SubjectId, so after the creation of the subject I have to create 2 SubjectMemebrs records in the SubjectMember Entity ? one for the creatorId  and one for the targetId ?


Help will be very appreciated.

Best regards,
Mohamed AlMokadem   

Solution

Hi Mohamed!

You are right about the SubjectId. It should be the same. The big question is in your data model.
For a 1-1 chat, it should be something like this 

Where MyUser, is the Id of the logged User (GetUserId()) and User should be the Id of the other person.

When loading your 1-1 chat screen, you should look for the SubjectId that is common between you and the person you selected from the list - assuming you have a list of available users. 

Because the other person can do the same, you should filter your UserId for both attributes:


If it's the first time you're opening that chat, you should use the CreateSubjectId action to get a SubjectId and create an entry to that relation entity:


Hope this helps.

Cheers,

Rui Mendes


Mohamed ElMokadem wrote:

Hello Mates, 

I'm Implementing a mobile chat app by using the In-App-Chat Mobile module features, but I'm confused about the subject ID creation in a One to One chat. 

Should we create a subject for each Chat Creator or One Subject only is enough and they both should use the same Subject ID. Same subject ID is the answer I think. 

So If they will share the same SubjectId, so after the creation of the subject I have to create 2 SubjectMemebrs records in the SubjectMember Entity ? one for the creatorId  and one for the targetId ?


Help will be very appreciated.

Best regards,
Mohamed AlMokadem   



Solution

Hi Rui, 

Yes this help too much Thank You so much for great details.

I just have a small question about the SubjectMember Entity in the App_Core module 


Should I insert 2 SubjectMember Record in the 1-1 chat ? for example 1 for MyUser(GetUserId()) and one for User target chat UserId ?

Because I see its joined with one UserId only. 


Thanks for help again.

Cheers,
Mohamed AlMokadem.