这是我什至 EventBus 的帖子。
fun startSpeedNotification() {
stats.startSession()
if (mSubscription == null &&
v2rayPoint.isRunning &&
settingsStorage?.decodeBool(AppConfig.PREF_SPEED_ENABLED) == true
) {
stats.startSession()
var lastZeroSpeed = false
val outboundTags = currentConfig?.getAllOutboundTags()
outboundTags?.remove(TAG_DIRECT)
mSubscription = Observable.interval(3, java.util.concurrent.TimeUnit.SECONDS)
.subscribe {
val queryTime = System.currentTimeMillis()
val sinceLastQueryInSeconds = (queryTime - lastQueryTime) / 1000.0
var proxyTotal = 0L
val text = StringBuilder()
outboundTags?.forEach {
val up = v2rayPoint.queryStats(it, "uplink")
val down = v2rayPoint.queryStats(it, "downlink")
if (up + down > 0) {
appendSpeedString(
text,
it,
up / sinceLastQueryInSeconds,
down / sinceLastQueryInSeconds
)
proxyTotal += up + down
stats.addUploadBytes(up.toInt())
stats.addDownloadBytes(down.toInt())
}
}
val directUplink = v2rayPoint.queryStats(TAG_DIRECT, "uplink")
val directDownlink = v2rayPoint.queryStats(TAG_DIRECT, "downlink")
sendStatsEvent(
stats.getTotalUploadBuckets(),
stats.getTotalDownloadBuckets(),
stats.getTotalUploadBytes(),
stats.getTotalDownloadBytes()
)
val zeroSpeed = (proxyTotal == 0L && directUplink == 0L && directDownlink == 0L)
if (!zeroSpeed || !lastZeroSpeed) {
if (proxyTotal == 0L) {
appendSpeedString(text, outboundTags?.firstOrNull(), 0.0, 0.0)
}
appendSpeedString(
text,
TAG_DIRECT,
directUplink / sinceLastQueryInSeconds,
directDownlink / sinceLastQueryInSeconds
)
updateNotification(
text.toString(),
proxyTotal,
directDownlink + directUplink
)
}
lastZeroSpeed = zeroSpeed
lastQueryTime = queryTime
}
}
}
private fun sendStatsEvent(ups: ArrayList<Int>, downs: ArrayList<Int>, up: Int, down: Int) {
EventBus.getDefault().post(Events.VpnToSfMsgEvent(ups, downs, up, down))
Log.d("graph_v2rayvpn", up.toString())
//here on the logs its recieving the bytes sent
}
这是我的活动课
object Events {
open class VpnToSfMsgEvent(ups:
ArrayList<Int>,
downs: ArrayList<Int>,
up: Int,
down: Int) {
val uploadBuckets = ups
val downloadBuckets = downs
val uploadBytes = up
val downloadBytes = down
}
}
在事件类中,我的日志显示错误 D/EventBus:没有为事件类注册的订阅者 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 没有为事件类 org.greenrobot.eventbus.NoSubscriberEvent 注册的订阅者
这是我的活动,试图接收要在图表上显示的数据
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(msg: Events.VpnToSfMsgEvent) {
val ups = msg.uploadBuckets
val downs = msg.downloadBuckets
val up = msg.uploadBytes
val down = msg.downloadBytes
Log.d("graph_mainactivity", ups.toString())
uploadGraph.update(
ups, "up"
)
downloadGraph.update(
downs, "downs"
)
uploadBytesView.text = Utils.byteCountToDisplaySize(
up.toLong(), false
)
downloadBytesView.text = Utils.byteCountToDisplaySize(
down.toLong(), false
)
}
这里没有收到我在我的 android studio 日志下面的 eventbus 帖子发布的任何数据
I/GoLog: Using Prepared: 104.18.10.207
D/graph_datatranf:1082 D/graph_datatnf:1082 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 注册订阅者 没有为事件类 org.greenrobot.eventbus.NoSubscriberEvent 注册订阅者 D/graph_v2rayvpn:1082 I /GoLog:使用 Prepared:104.18.10.207 D/graph_datatranf:2598 D/graph_datatnf:3680 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 注册的订阅者没有为事件类 org.greenrobot 注册的订阅者。 eventbus.NoSubscriberEvent D/graph_v2rayvpn: 3680 I/GoLog: tcp:127.0.0.1:53508 接受 tcp:52.214.116.160:443 [proxy] I/GoLog: Using Prepared: 104.18.10.207 D/graph_datatranf: 800 D/graph_datatnf: 4480 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 注册的订阅者 没有为事件类 org 注册的订阅者。greenrobot.eventbus.NoSubscriberEvent D/graph_v2rayvpn: 4480 D/graph_datatnf: 4480 D/EventBus: 没有订阅者注册事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 没有订阅者注册事件类 org.greenrobot.eventbus.NoSubscriberEvent D /graph_v2rayvpn: 4480 I/GoLog: tcp:127.0.0.1:53514 接受 tcp:52.48.209.44:443 [proxy] I/GoLog: 使用 Prepared: 104.18.10.207 D/graph_datatranf: 750 D/graph_datatnf: 5230 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent D/EventBus 注册订阅者:没有为事件类 org.greenrobot.eventbus.NoSubscriberEvent D/graph_v2rayvpn 注册订阅者:5230 I/GoLog:EscortingDown() 杀死所有被护送的进程I/GoLog:EscortRun cmd.Wait 错误:等待:没有子进程4480 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 注册订阅者 没有为事件类 org.greenrobot.eventbus.NoSubscriberEvent 注册订阅者 D/graph_v2rayvpn:4480 I/GoLog:tcp:127.0.0.1: 53514 接受 tcp:52.48.209.44:443 [proxy] I/GoLog: 使用 Prepared: 104.18.10.207 D/graph_datatranf: 750 D/graph_datatnf: 5230 D/EventBus: 没有为事件类 com.namelessnetx.ang.util 注册的订阅者。 Events$VpnToSfMsgEvent D/EventBus: 没有为事件类注册的订阅者 org.greenrobot.eventbus.NoSubscriberEvent D/graph_v2rayvpn: 5230 I/GoLog: EscortingDown() Killing all escorted process I/GoLog: EscortRun cmd.Wait err: wait: no child流程4480 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 注册订阅者 没有为事件类 org.greenrobot.eventbus.NoSubscriberEvent 注册订阅者 D/graph_v2rayvpn:4480 I/GoLog:tcp:127.0.0.1: 53514 接受 tcp:52.48.209.44:443 [proxy] I/GoLog: 使用 Prepared: 104.18.10.207 D/graph_datatranf: 750 D/graph_datatnf: 5230 D/EventBus: 没有为事件类 com.namelessnetx.ang.util 注册的订阅者。 Events$VpnToSfMsgEvent D/EventBus: 没有为事件类注册的订阅者 org.greenrobot.eventbus.NoSubscriberEvent D/graph_v2rayvpn: 5230 I/GoLog: EscortingDown() Killing all escorted process I/GoLog: EscortRun cmd.Wait err: wait: no child流程eventbus.NoSubscriberEvent D/graph_v2rayvpn: 4480 I/GoLog: tcp:127.0.0.1:53514 接受 tcp:52.48.209.44:443 [proxy] I/GoLog: Using Prepared: 104.18.10.207 D/graph_datatranf: 750 D/graph_datatnf: 5230 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 注册的订阅者 D/EventBus:没有为事件类 org.greenrobot.eventbus.NoSubscriberEvent 注册的订阅者 D/graph_v2rayvpn:5230 I/GoLog:EscortingDown()杀死所有护送进程 I/GoLog: EscortRun cmd.Wait err: wait: no child processeseventbus.NoSubscriberEvent D/graph_v2rayvpn: 4480 I/GoLog: tcp:127.0.0.1:53514 接受 tcp:52.48.209.44:443 [proxy] I/GoLog: Using Prepared: 104.18.10.207 D/graph_datatranf: 750 D/graph_datatnf: 5230 D/EventBus:没有为事件类 com.namelessnetx.ang.util.Events$VpnToSfMsgEvent 注册的订阅者 D/EventBus:没有为事件类 org.greenrobot.eventbus.NoSubscriberEvent 注册的订阅者 D/graph_v2rayvpn:5230 I/GoLog:EscortingDown()杀死所有护送进程 I/GoLog: EscortRun cmd.Wait err: wait: no child processes没有订阅者注册事件类 org.greenrobot.eventbus.NoSubscriberEvent D/graph_v2rayvpn: 5230 I/GoLog: EscortingDown() 杀死所有被护送的进程 I/GoLog: EscortRun cmd.Wait err: 等待: 没有子进程没有订阅者注册事件类 org.greenrobot.eventbus.NoSubscriberEvent D/graph_v2rayvpn: 5230 I/GoLog: EscortingDown() 杀死所有被护送的进程 I/GoLog: EscortRun cmd.Wait err: 等待: 没有子进程