great...many thanks for all this explanation!

I've changed for the way you said [1] and it's working.

Just one more question: I don't know if this is related to telepathy but
when I receive a message at Empathy and the chat window is not open, it
appears a little box at the bottom of the screen with that message. I saw
at the debug log that a new channel is being created. When I click this
box, it opens the chat window but the messages received while the chat
window was closed doesn't appears there. Do you know if there is some
property of the request map that I should set to maintain these received
messages with window chat closed?


[1]
https://github.com/resiprocate/resiprocate/compare/master...MateusBellomo:mateus-presence-text#diff-82d1d1ba25e34af050fd6a6c5e5311dfR483

2016-07-23 5:09 GMT-03:00 George Kiagiadakis <gkia...@tolabaki.gr>:

> On 23.07.2016 07:16, Mateus Bellomo wrote:
>
>> George,
>>
>> I could make it work but for that I have swaped the initiatorHandle and
>> targetHandle on the onMessageReceived() method. You could see at [1] what
>> I
>> did. Doing this, the channel created has the same parameters when I do a
>> createChannel() [2] operation and the message sent and receive are now
>> appearing at same window [3].
>>
>> I don't know if this implementation is the most suitable, what do you
>> think?
>>
>> [1]
>>
>> https://github.com/resiprocate/resiprocate/compare/master...MateusBellomo:mateus-presence-text#diff-82d1d1ba25e34af050fd6a6c5e5311dfR498
>> [2]
>>
>> https://github.com/resiprocate/resiprocate/compare/master...MateusBellomo:mateus-presence-text#diff-82d1d1ba25e34af050fd6a6c5e5311dfR650
>> [3] https://mateusbellomo.wordpress.com/
>>
>>
> No, this doesn't look correct. First of all, I can see targetHandle is
> assigned to the contact from the "to" header, and since this is a "message
> received" method, the "to" is your self contact, not the remote one. In 1-1
> channels, TargetHandle must be the remote contact.
>
> I just had a look at how telepathy-qt implements ensureChannel() and now I
> fully understand what telepathy-morse is doing there too...
>
> So, ensureChannel() will check if there is already a channel for this
> message and if there is, it will use it, otherwise it will create a new
> one. When you receive a new message for an existing channel, it is
> practically impossible to know who is the "initiator", i.e. who started the
> channel. If the channel is already created, then it is the channel that
> knows this information, not the message. Therefore, ensureChannel() does
> *not* use the "InitiatorHandle" to match an existing channel, it only uses
> the "TargetHandleType" and "TargetHandle". But, if the channel is not
> already created, then it creates it. In this case, it needs to know who is
> the initiator and uses the "InitiatorHandle" property.
>
> What does this mean for your code? It means that "TargetHandleType" and
> "TargetHandle" identify your channel and "InitiatorHandle" identify the
> contact that would be initiating the channel if it wasn't already created.
> To explain it in a simple map:
>
> * Receiving a message from a remote contact on a 1-to-1 chat:
> TargetHandleType: contact
> TargetHandle: remote contact handle
> InitiatorHandle: remote contact handle
>
> * Sending a message to a remote contact on a 1-to-1 chat:
> TargetHandleType: contact
> TargetHandle: remote contact handle
> InitiatorHandle: local 'self' contact handle
>
> * Receiving a message from a remote contact on a room:
> TargetHandleType: room
> TargetHandle: room handle
> InitiatorHandle: remote contact handle
>
> * Sending a message to a remote contact on a room:
> TargetHandleType: room
> TargetHandle: room handle
> InitiatorHandle: local 'self' contact handle
>
> Practically, your onMessageReceived() method falls in the first of the 4
> cases above, so "TargetHandle" and "InitiatorHandle" actually need to be
> the same contact handle, the one from the h_From header. Telepathy-morse
> also tries to cover the 3rd case (room), which is why it is a bit more
> confusing.
>
> George
>
>
> _______________________________________________
> telepathy mailing list
> telepathy@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/telepathy
>
_______________________________________________
telepathy mailing list
telepathy@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/telepathy

Reply via email to