Simplificator3000Phoenix.Channel (Simplificator3000 Phoenix v1.2.1)
Summary
Functions
Defines a message handler.
Permissions can be passed via opts
param to validate request's rights.
Event handler receives parsed and validated payload.
A shorter version of full-fat message
macro. The difference is that this helper manages to execute your code in separate process, prepares ctx
and then automatically sends response with metadata and request_id set up (no longer shall we forget to send this extra data)
Defines a payload schema for first following message handler (that consumes the schema and prevents further use of this schema).
Payload schema is a map with keys and types.
For schema documentation see Tarams
library.
Creates a handle_info
definition which simplifies the syntax required for this code.
From this
Functions
Defines a message handler.
Permissions can be passed via opts
param to validate request's rights.
Event handler receives parsed and validated payload.
Options
- `:unauthorized_handler` - function to be called when user is not authorized to perform the action.
- `:invalid_params_handler` - function to be called when params are invalid.
- `:permissions` - list of permissions to check.
Examples
1. As a function definition:
```
message event_name(payload, socket) do
# Code
end
```
2. As a function declaration:
```
message(
:event_name,
payload_template,
opts
)
def event_name(payload, socket) do
# Code
end
```
This way you can create event handler by yourself thus allowing you to make use of multiple function pattern matching.
A shorter version of full-fat message
macro. The difference is that this helper manages to execute your code in separate process, prepares ctx
and then automatically sends response with metadata and request_id set up (no longer shall we forget to send this extra data)
Defines a payload schema for first following message handler (that consumes the schema and prevents further use of this schema).
Payload schema is a map with keys and types.
For schema documentation see Tarams
library.
Creates a handle_info
definition which simplifies the syntax required for this code.
From this:
def handle_info({:event, param1, param2, ...}, socket) do
...code
{:noreply, socket}
end
To this:
sub event(param1, param2, ..., socket) do
...code
{:noreply, socket}
end