Thing-Connection in eclipse ditto

98 Views Asked by At
  1. Can a single thing have multiple connection, if so can all of them be active at the same time?

  2. I'm exploring the eclipse ditto recently and I wanted to know whether below given approach is correct for finding the connection a 'thing' uses. I'm trying to get the connection a 'thing' uses, by mapping the thing-policy's authorization subject with authorization context of connections.

const matchingSourceConnection = connections.filter((connection) => {
    return (
        connection.sources &&
        connection.sources[0].authorizationContext &&
        connection.sources[0].authorizationContext.some((context) => authorizationSubjects.includes(context))
    ); 
});

Thank you!

1

There are 1 best solutions below

1
On

This code checks each source in every connection, which can provide a more comprehensive match.

const matchingSourceConnection = connections.filter((connection) => {
    return connection.sources &&
        connection.sources.some(source => 
            source.authorizationContext &&
            source.authorizationContext.some((context) => authorizationSubjects.includes(context))
        ); 
});