Comments (6)
@SergeyBurlaka Hello. Can you describe what's the problem in more detail?
What do you mean by "redundant links"?
from underdark-android.
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.
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.
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.
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.
I think now everything became very clear. Thanks
from underdark-android.
Related Issues (20)
- shouldPairDevice always returns true? HOT 5
- . HOT 1
- Problem of file transfers HOT 13
- Crashing on simulator HOT 1
- Transfer audio / video or any buffer HOT 6
- Enable logging HOT 5
- Crash relative to Bluetooth usage HOT 10
- Lots of packages missing? HOT 2
- can work only with wifi? HOT 2
- app is crashing on uploading image. HOT 1
- Bluetooth LE advertising doesn't work even with Peripheral mode Device HOT 15
- How to change the Activity without loosing Connection HOT 3
- bluetooth address null on Android OREO HOT 7
- routing algorithm HOT 2
- Unable to connect multiple devices
- Current Version
- Status of developement (Android, IOS) HOT 3
- jcenter and bintray shut down. Can no longer compile this library. HOT 2
- Documentation HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from underdark-android.