-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from mysteriumnetwork/10-tunnel-status
10 tunnel status
- Loading branch information
Showing
27 changed files
with
443 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
android/src/main/kotlin/network/mysterium/wireguard_dart/ConnectionStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package network.mysterium.wireguard_dart | ||
|
||
import com.wireguard.android.backend.Tunnel | ||
|
||
enum class ConnectionStatus { | ||
disconnected, connected, connecting, disconnecting, unknown; | ||
|
||
companion object { | ||
fun fromTunnelState(state: Tunnel.State?): ConnectionStatus = when (state) { | ||
Tunnel.State.UP -> connected | ||
Tunnel.State.DOWN -> disconnected | ||
else -> unknown | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
android/src/main/kotlin/network/mysterium/wireguard_dart/ConnectionStatusBroadcaster.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package network.mysterium.wireguard_dart | ||
|
||
import android.os.Handler | ||
import android.os.Looper | ||
import io.flutter.plugin.common.EventChannel | ||
import io.flutter.plugin.common.EventChannel.EventSink | ||
import io.flutter.plugin.common.EventChannel.StreamHandler | ||
|
||
class ConnectionStatusBroadcaster : StreamHandler { | ||
|
||
private var eventSink: EventSink? = null | ||
override fun onListen(arguments: Any?, events: EventChannel.EventSink?) { | ||
eventSink = events | ||
} | ||
|
||
override fun onCancel(arguments: Any?) { | ||
eventSink = null | ||
} | ||
|
||
fun send(status: ConnectionStatus) { | ||
Handler(Looper.getMainLooper()).post { | ||
eventSink?.success(hashMapOf("status" to status.name)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.