Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Lockup #23

Closed
skram opened this issue Sep 22, 2017 · 4 comments
Closed

App Lockup #23

skram opened this issue Sep 22, 2017 · 4 comments

Comments

@skram
Copy link

skram commented Sep 22, 2017

Using the exact example code, after running the server..the app freezes, but the server is still accessible. Any ideas as to what may be going wrong? If I comment out loop.runForever() it doesn't happen..but the server doesn't work. using Xcode 9 on iOS 11 Swift 3.

import Embassy
import EnvoyAmbassador

let loop = try! SelectorEventLoop(selector: try! KqueueSelector())
let router = Router()
let server = DefaultHTTPServer(eventLoop: loop, port: 8080, app: router.app)

router["/api/v2/users"] = DelayResponse(JSONResponse(handler: { _ -> Any in
    return [
        ["id": "01", "name": "john"],
        ["id": "02", "name": "tom"]
    ]
}))

// Start HTTP server to listen on the port
try! server.start()

// Run event loop
loop.runForever()```
@skram skram changed the title UI Lockup App Lockup Sep 22, 2017
@fangpenlin
Copy link
Contributor

@skram Like runForever implies, it blocks current thread you're running it on. So if you want the UI event loop works along with the Embassy server, please use another thread, like NSThread.

@skram
Copy link
Author

skram commented Oct 4, 2017

@fangpenlin mind sharing an example of how to do so with above as an example? having difficulty with this. Much appreciated.

@fangpenlin
Copy link
Contributor

@skram you can see how we use NSThread to run it in a separate thread here in this article

https://envoy.engineering/embedded-web-server-for-ios-ui-testing-8ff3cef513df

@skram
Copy link
Author

skram commented Oct 5, 2017

Thanks. Actually, I just resolved it prior to your response with the same resource link. Thanks.

@skram skram closed this as completed Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants