Git Product home page Git Product logo

Comments (6)

virl avatar virl commented on June 25, 2024

@SergeyBurlaka Hello. Can you describe what's the problem in more detail?
What do you mean by "redundant links"?

from underdark-android.

SergeyBurlaka avatar SergeyBurlaka commented on June 25, 2024

I create connection betwen only 2 device via 2 nodes So i need only 2 links connected
So i watch how many links connect by logs here:

 //on connection
    override fun transportLinkConnected(transport: Transport, link: Link) {
        mLinks.add(link)

        Log.d(TAG, "transportLinkConnected Link = $link")
      
        when (type) {
            NodeType.MESSAGE -> dataTransfer?.onRefreshedPeersMessage(mLinks.size)

            NodeType.SOUND -> dataTransfer?.onRefreshedPeersSound(mLinks.size)
        }
    }

For connection i created Node object, here my Kotlin code:

class Node(context: Context, private var dataTransfer: DataTransfer?, private val type: NodeType, appId: Int)
    : TransportListener

 init {
        do {
            mNodeId = Random().nextLong()
        } while (mNodeId == 0L)

        if (mNodeId < 0)
            mNodeId = -mNodeId

        configureLogging()
        val kinds = EnumSet.of(TransportKind.WIFI)

        this.mTransport = Underdark.configureTransport(
                appId, mNodeId, this, null,
                context.applicationContext, kinds
        )
    }

And first time see 2 connected links in logs:

..../Node: transportLinkConnected Link = alink(1) nodeId 7855185628251833254
--
... D/Node: transportLinkConnected Link = alink(1) nodeId 4618952656116501996

It is work greate.

But then i try unconnect,

public void disconnect() {
        this.transport.queue.dispatch(new Runnable() {
            public void run() {
                Iterator var1 = AggLink.this.links.iterator();

                while(var1.hasNext()) {
                    Link link = (Link)var1.next();
                    link.disconnect();
                }

            }
        });
    }

and connect again

And quantity of connection links is growing:

//Connected
...D/Node: transportLinkConnected Link = alink(1) nodeId 7376268880458696257
--
..... D/Node: transportLinkConnected Link = alink(0) nodeId 755959319961052674
--
//Disconnected
...D/Node: transportLinkDisconnected  Link = alink(0) nodeId 755959319961052674
--
...D/Node: transportLinkDisconnected  Link = alink(0) nodeId 7376268880458696257

Connected
.... D/Node: transportLinkConnected Link = alink(1) nodeId 3420549108642149074

.....D/Node: transportLinkConnected Link = alink(0) nodeId 5710137947420927346

//Disconnected
.... D/Node: transportLinkDisconnected  Link = alink(0) nodeId 5710137947420927346

.....D/Node: transportLinkDisconnected  Link = alink(0) nodeId 3420549108642149074

....D/Node: transportLinkConnected Link = alink(1) nodeId 7855185628251833254

This is because the old links are not completely destroyed, but new links are created.
Maybe there's no problem here?
So how i must disconnect the botch devices?

from underdark-android.

virl avatar virl commented on June 25, 2024

I create connection betwen only 2 device via 2 nodes So i need only 2 links connected

Connection even between two devices can spawn arbitrary number of links even with single transport kind (for ex, Wi-Fi) with the same nodeId.

So how i must disconnect the botch devices?

You can implment disconnection business logic on top of connected links.

from underdark-android.

SergeyBurlaka avatar SergeyBurlaka commented on June 25, 2024

You can implment disconnection business logic on top of connected links.

So, you meen it not necessary to call link.disconnect()*, instead i can use some status flag in message,
to report disconnection.

*disconnect() is method from Underdark:

public void disconnect() {
        this.transport.queue.dispatch(new Runnable() {
            public void run() {
                Iterator var1 = AggLink.this.links.iterator();

                while(var1.hasNext()) {
                    Link link = (Link)var1.next();
                    link.disconnect();
                }

            }
        });
    }

from underdark-android.

virl avatar virl commented on June 25, 2024

So, you meen it not necessary to call link.disconnect()*, instead i can use some status flag.

Yes, you can implement your logical disconnection on top of long-lived links.

from underdark-android.

SergeyBurlaka avatar SergeyBurlaka commented on June 25, 2024

I think now everything became very clear. Thanks

from underdark-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.