aboutsummaryrefslogtreecommitdiff
path: root/lib/websocket/handler.go
AgeCommit message (Collapse)Author
2026-01-03all: use SPDX license header formatShulhan
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2020-08-11websocket: add server options to change the connect and status pathsShulhan
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.
2020-03-12websocket: explain the error behaviour on ClientHandlerShulhan
2019-03-17websocket: simplify client handshake process without handler and contextShulhan
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.
2019-03-17websocket: pass the instance of client to handlerShulhan
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.
2019-03-17websocket: rewrite client to use centralized handlerShulhan
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.
2019-03-10websocket: add server handler for reserved control frameShulhan
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.
2019-03-07websocket: add unit test for client servePingShulhan
The test require to add a new handler on server to check received control PONG frame from client.
2019-03-06websocket: remove server HandleClose, duplicate with HandleClientRemoveShulhan
Also, rename HandlerPayload to HandlerPayloadFn, to make it clear that the type is a function (or callback, as we called it).
2019-03-06websocket: refactoring handling fragmentation on serverShulhan
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.
2019-03-04websocket: minimize global variables and unexport internal constantsShulhan
Most of the constants should not be used directly, as we prefer user to use the functions or methods based access.
2018-11-29all: fixes warning from lintersShulhan
2018-07-06Add implementation of websocket server and client (RFC 6455)Shulhan