{"action":"created","issue":{"url":"https://api.github.com/repos/TooTallNate/Java-WebSocket/issues/817","repository_url":"https://api.github.com/repos/TooTallNate/Java-WebSocket","labels_url":"https://api.github.com/repos/TooTallNate/Java-WebSocket/issues/817/labels{/name}","comments_url":"https://api.github.com/repos/TooTallNate/Java-WebSocket/issues/817/comments","events_url":"https://api.github.com/repos/TooTallNate/Java-WebSocket/issues/817/events","html_url":"https://github.com/TooTallNate/Java-WebSocket/issues/817","id":384027808,"node_id":"MDU6SXNzdWUzODQwMjc4MDg=","number":817,"title":"How can I integrate the WebSocketClient with an event loop?","user":{"login":"haelix888","id":41542548,"node_id":"MDQ6VXNlcjQxNTQyNTQ4","avatar_url":"https://avatars2.githubusercontent.com/u/41542548?v=4","gravatar_id":"","url":"https://api.github.com/users/haelix888","html_url":"https://github.com/haelix888","followers_url":"https://api.github.com/users/haelix888/followers","following_url":"https://api.github.com/users/haelix888/following{/other_user}","gists_url":"https://api.github.com/users/haelix888/gists{/gist_id}","starred_url":"https://api.github.com/users/haelix888/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haelix888/subscriptions","organizations_url":"https://api.github.com/users/haelix888/orgs","repos_url":"https://api.github.com/users/haelix888/repos","events_url":"https://api.github.com/users/haelix888/events{/privacy}","received_events_url":"https://api.github.com/users/haelix888/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-24T22:32:47Z","updated_at":"2018-11-26T09:11:13Z","closed_at":null,"author_association":"NONE","body":"I need to integrate the WebSocketClient with a different connection inside the same app. This would require the use of something like the java.nio.channels.SelectableChannel, which you poll using select(), possibly together with other pollables.\r\n\r\nThe documentation states \"The underlying classes are implemented [using] java.nio, which allows for a non-blocking event-driven model\", but this probably refers to the server-side WebSocket? It seems on the client-side one is expected to create a thread for the reading. This is not ideal.\r\n\r\n**Describe the solution you'd considered**\r\nIdeally the internals of the WebSocket should expose the event loop, or allow integration with an application-provided event loop.\r\nThe poorer alternative would be, for the application to create a reader thread which onMessage will push messages to a (pollable) blocking queue, which can in turn be used with select() or a similar non-blocking mechanism.\r\n"},"comment":{"url":"https://api.github.com/repos/TooTallNate/Java-WebSocket/issues/comments/441567458","html_url":"https://github.com/TooTallNate/Java-WebSocket/issues/817#issuecomment-441567458","issue_url":"https://api.github.com/repos/TooTallNate/Java-WebSocket/issues/817","id":441567458,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTU2NzQ1OA==","user":{"login":"haelix888","id":41542548,"node_id":"MDQ6VXNlcjQxNTQyNTQ4","avatar_url":"https://avatars2.githubusercontent.com/u/41542548?v=4","gravatar_id":"","url":"https://api.github.com/users/haelix888","html_url":"https://github.com/haelix888","followers_url":"https://api.github.com/users/haelix888/followers","following_url":"https://api.github.com/users/haelix888/following{/other_user}","gists_url":"https://api.github.com/users/haelix888/gists{/gist_id}","starred_url":"https://api.github.com/users/haelix888/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haelix888/subscriptions","organizations_url":"https://api.github.com/users/haelix888/orgs","repos_url":"https://api.github.com/users/haelix888/repos","events_url":"https://api.github.com/users/haelix888/events{/privacy}","received_events_url":"https://api.github.com/users/haelix888/received_events","type":"User","site_admin":false},"created_at":"2018-11-26T09:11:13Z","updated_at":"2018-11-26T09:11:13Z","author_association":"NONE","body":"It's a poorer alternative in terms of performance of an application which is otherwise draught designed as single threaded (event driven), because it implies the additional thread switch and somewhat more code.\r\n\r\nCan you please confirm my assumption above? \"It seems on the client-side one is expected to create a thread for the reading.\".  Is that how normally the WebSocket is integrated into apps? Thanks."}}
{"actor":{"display_login":"haelix888"}}