Skip to content

Commit 4ebefb9

Browse files
authored
Clarify Socket <-> Transport boundary
1 parent 0079ad0 commit 4ebefb9

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lib/phoenix/socket/transport.ex

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ defmodule Phoenix.Socket.Transport do
33
Outlines the Socket <-> Transport communication.
44
55
Each transport, such as websockets and longpolling, must interact
6-
with a socket. This module defines said behaviour.
6+
with a socket. This module defines the functions a transport will
7+
invoke on a given socket implementation.
78
89
`Phoenix.Socket` is just one possible implementation of a socket
910
that multiplexes events over multiple channels. If you implement
10-
this behaviour, then a transport can directly invoke your
11+
this behaviour, then existing transports can use your new socket
1112
implementation, without passing through channels.
1213
13-
This module also provides convenience functions for implementing
14-
transports.
14+
This module also provides guidelines and convenience functions for
15+
implementing transports. Albeit its primary goal is to aid in the
16+
definition of custom sockets.
1517
1618
## Example
1719
@@ -60,7 +62,8 @@ defmodule Phoenix.Socket.Transport do
6062
6163
Sockets are operated by a transport. When a transport is defined,
6264
it usually receives a socket module and the module will be invoked
63-
when certain events happen at the transport level.
65+
when certain events happen at the transport level. The functions
66+
a transport can invoke are the callbacks defined in this module.
6467
6568
Whenever the transport receives a new connection, it should invoke
6669
the `c:connect/1` callback with a map of metadata. Different sockets
@@ -81,15 +84,16 @@ defmodule Phoenix.Socket.Transport do
8184
reason `:closed` can be used to specify that the client terminated
8285
the connection.
8386
84-
## Booting
87+
### Booting
8588
86-
Whenever your endpoint starts, it will automatically invoke the
87-
`child_spec/1` on each listed socket and start that specification
88-
under the endpoint supervisor.
89+
When you list a socket under `Phoenix.Endpoint.socket/3`, Phoenix
90+
will automatically start the socket module under its supervision tree,
91+
however Phoenix does not manage any transport.
8992
90-
Since the socket supervision tree is started by the endpoint,
91-
any custom transport must be started after the endpoint in a
92-
supervision tree.
93+
Whenever your endpoint starts, Phoenix invokes the `child_spec/1` on
94+
each listed socket and start that specification under the endpoint
95+
supervisor. Since the socket supervision tree is started by the endpoint,
96+
any custom transport must be started after the endpoint.
9397
"""
9498

9599
@type state :: term()

0 commit comments

Comments
 (0)