Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jjcarstens/phx_server_sync
And idea for handling synchronous requests from the server on a channel and support distribution.
https://github.com/jjcarstens/phx_server_sync
Last synced: 22 days ago
JSON representation
And idea for handling synchronous requests from the server on a channel and support distribution.
- Host: GitHub
- URL: https://github.com/jjcarstens/phx_server_sync
- Owner: jjcarstens
- Created: 2020-04-19T17:32:45.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T03:47:53.000Z (about 2 years ago)
- Last Synced: 2024-10-30T15:54:45.736Z (2 months ago)
- Language: Elixir
- Size: 1.38 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Phoenix Synchronous Server requests example
And idea for handling synchronous requests from the server on a channel and support distribution.
Specifically for [this forum question](https://elixirforum.com/t/how-to-send-request-to-phoenix-channel-client/19009/2)
## Test
Start the `server` and `client` apps separately:
```sh
$ cd server && iex -S mix phx.server
``````sh
$ cd client && iex -S mix
```The `client` app starts a single channel for device ID `1`. Make a request to it from the server shell session
```elixir
Server.Requestor.send(1, "request", %{})
```The client gets the request and sleeps for a random time between 1-10 seconds. It out puts a log. The server call should be blocking
![async_server_request](async_server_request.png)