admin 管理员组文章数量: 1086019
I'm learning to use reactor-netty to create a TCP server with UI, and I have to do something like send a message to client then send other after 10s when I push a button.Here is my code
val fx = Flux<ReqContext>.create { sink ->
record10sButton.addActionListener(ActionListener { event: ActionEvent? ->
sink.next(StartMessage)
sleep(10000)
sink.next(StopMessage)
EventQueue.invokeLater{
JOptionPane.showMessageDialog(
this, "complete",
"record 10s",
JOptionPane.INFORMATION_MESSAGE
)
}
})
}
The above code is the listener of the button, I copy and modify it from reactor document
val tcpServer =
TcpServer.create()
.host("localhost")
.port(50000)
.handle { inbound: NettyInbound?, outbound: NettyOutbound? ->
inbound!!.receiveObject().then().
and(outbound!!.sendObject(fx).then())
}
.wiretap(true)
And here is the code of server
The behavior of this button confused me, the interval of two message seems related on the number of connection, when 3 clients connected, client receive second message after 30s. I want to know how to fix that
本文标签: kotlinHow to use flux to send 2 message at fixed intervalsStack Overflow
版权声明:本文标题:kotlin - How to use flux to send 2 message at fixed intervals - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744094577a2532660.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论