3.0.0
Stable release compatible with AMPHP v3 and fibers! 🎉
This release is compatible with amphp/http-server@^3
and amphp/websocket@^2
.
As with other libraries compatible with AMPHP v3, most cases of parameters or returns of Promise<ResolutionType>
have been replaced with ResolutionType
.
Similar to v2
, a Websocket is created by creating an instance of Websocket
and using it as a request handler on an HTTP server. However, the constructor arguments have changed to reflect the changes below and the removal of the Options
object from amphp/websocket
.
A gateway object is no longer provided automatically to a client handler. A client handler may create one or more WebsocketClientGateway
objects to hold a collection of clients and asynchronously broadcast messages to all (or only some) clients within a gateway.
- Renamed most classes and interfaces to add
Websocket
as a prefix to avoid name collisions with similarly named classes in other packages which are frequently used together. For example,ClientHandler
is nowWebsocketClientHandler
,ClientFactory
is nowWebsocketClientFactory
. - The handshake accepting functionality of
ClientHandler
has been split into a separate interface,WebsocketAcceptor
. In general, most applications will want to useAllowOriginAcceptor
. For more flexibility, create your own implementation by delegating toRfc6455Acceptor
and adding your own logic inhandleHandshake()
. WebsocketServerObserver
has been removed. Use theonStart()
andonStop()
methods ofHttpServer
if an action is needed when starting or stopping the HTTP server.