Thing-Connection in eclipse ditto

87 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 answers

1
Gökhan Baştürk 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))
        ); 
});