| Age | Commit message (Collapse) | Author |
|
|
|
|
|
Previously, there is only one option for server, the port where it will
listen.
This changes add option to change the connect path (default to "/"
previously) and new path and handler for retrieving server status.
|
|
|
|
User of library that want to create WebSocket client should only focus
to the Endpoint and/or Headers when creating client.
While at it, change handshake test to check for error instead of status
code.
|
|
Since handler are created before creating a client and a handler may
send a response to server after receiving a message from server, we pass
the current client to handler as parameter.
|
|
Unlike HTTP client or other most commmon TCP oriented client, the
WebSocket client is actually asynchronous or passive-active instead of
synchronous.
At any time client connection is open to server, client can receive a
message broadcast from server.
Case examples: if client send "A" to server, and expect that server
response with "A+", server may send message "B" before sending "A+".
Another case is when client connection is open, server may send "B" and
"C" in any order without any request send by client previously.
Due to this model, the way to handle response from server is centralized
using handlers instead of using single send request-response.
|
|
The handler is called HandlerRsvControl that can be set before running
the server. Default HandlerRsvControl is nil.
Since the handler expect Frame as parameter, we need to adjust and add
two methods to access Frame's internal fields and methods; which is
exporting NewFrame function and Frame.Pack method, and adding method
Opcode() and Payload() to access Frame's opcode and payload.
|
|
The test require to add a new handler on server to check received control
PONG frame from client.
|
|
Also, rename HandlerPayload to HandlerPayloadFn, to make it clear that
the type is a function (or callback, as we called it).
|
|
The temporary storage for continuous frame is moved from server to
ClientManager, to prevent data race when modifying it and to allow one
central function to clear it (when client closed).
Another changes is on server handle parameter on HandleText and HandleBin.
Previously, we pass the frame to handler, now we pass the payload since
that is the real message the client send.
|
|
Most of the constants should not be used directly, as we prefer user to
use the functions or methods based access.
|
|
|
|
|