| Age | Commit message (Collapse) | Author |
|
Go 1.22 now support for-range on numeric value.
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
There are some reports that I disagree with revive, in example, code
should not declare the type after variables.
In my opinion, on some cases, declaring the type make the code more
readable and explicit.
Since I did not want to add new configuration file, we changes it and
follow revive for now.
|
|
The ReadWriteTimeout define the maximum duration the server wait when
receiving/sending packet from/to client before considering the
connection as broken.
Default read-write timeout is 30 seconds if not set.
This changes affect the exported function Send and Recv by adding
additional parameter timeout to both of them.
|
|
The Client have method send that check if the underlying connection (conn)
has been closed or not.
Since the conn can be closed anytime, for example server send to the
control CLOSE frame:
recv -> handleFrame -> handleClose -> Quit
we need to guard the conn with Mutex before calling send to prevent
data race.
|
|
Replace assignment from using ":=" to use variable declaration with
type.
Rationale: clarity and minimize duplicate temporary variables with the
same type.
|
|
|
|
|
|
|
|
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.
|
|
Requesting "GET /health" on WebSocket server will return HTTP status
code 204, which can be used for service health checking.
|
|
|
|
This is to prevent the actual test running before server is ready, which
cause the test sometimes fails.
|
|
|
|
The valid syntax to suppress linter warnings is "//nolint:<name>" with
no space between comment and "nolint" and between ":". Also, we move the
placement of nolint directive to the top of statements for multiple
nolint in the same scope.
While at it, fix and supress some linter warnings.
|
|
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.
|
|
Another possibility is fragmented frames with one of the frame is
chopped and in the middle of it is a control FRAME. For example,
C> Frame{fin:false opcode:TEXT len:1024 payload:512}
C> payload:512 FRAME{fin:TRUE opcode:PING len:0}
C> Frame{fin:true opcode:0 len:1024 payload:1024}
|
|
|
|
|
|
Also, make sure we close the client connection from unit test.
|
|
Previously, client connection state is used to disallow send or receive
if client is not connected to remote server. This check also can be
done by checking for nil on connection field.
|
|
Use the log package with prefix instead of fmt.Fprintln.
|
|
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.
|
|
ClientManager manage all of active connection in server.
The ClientManager is part of the Server now, instead of separated instance.
|
|
Continuing refactor, this commit unexport all fields in Frame to allow
user focus working with method and packet, let the technical detail
managed by library.
|
|
This is for easily peek the global variables name when doing grep.
|
|
Most of the constants should not be used directly, as we prefer user to
use the functions or methods based access.
|
|
The client API now contains only NewClient() to create and connect to
remote server, Send() to send package to remote server, and Recv() to
receive package from remote.
All fields and methods that is directly related to client usage are
unexported.
|
|
Most of the warnings caused by update to linter which cause global
variables declared with grouping "( ... )" and that has been suppressed,
are become false-positive again.
|
|
|
|
|
|
|
|
|