I have a websocket server which executed on a background thread like this:
DispatchQueue.global(qos: .userInteractive).async {
let server = SecondServer()
server.run()
}
But there is a problem. websocket server only responds to client commands when the app is on top. for example, when I run browser and send websocket command, the server doesn't respond until I bring my app on top. Is there any solution to help me that I can run my server on the background and my app doesn't need to be on top?
Post
Replies
Boosts
Views
Activity
I used SwiftNIO as a websocket server according to this link, and it works fine when I execute it on the main thread but when I run it on the background of main thread like this
DispatchQueue.global(qos: .userInitiated).async {
let server = SecondServer()
server.run()
}
it doesn't receive any message from client. this is my server code:
My websocket server code
Can anybody help me to solve my problem? Thanks.