Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Connect()
- func (c *Client) Disconnect()
- func (c *Client) DisconnectGracefully(code uint16, message string)
- func (c *Client) GetConnectedTo() int
- func (c *Client) GetConnectingTo() int
- func (c *Client) GetConnection(connectionNr int) *connection.Connection
- func (c *Client) GetConnections() []*connection.Connection
- func (c *Client) GetLatency()
- func (c *Client) HasOnConnectFailedAll(name string) bool
- func (c *Client) HasOnConnectSuccess(name string) bool
- func (c *Client) IsConnected() bool
- func (c *Client) IsConnecting() bool
- func (c *Client) LDebug() *zerolog.Event
- func (c *Client) LDebugF(functionName string) *zerolog.Event
- func (c *Client) LError() *zerolog.Event
- func (c *Client) LErrorF(functionName string) *zerolog.Event
- func (c *Client) LEvent(eventType string, eventName string, beforeMsg func(event *zerolog.Event))
- func (c *Client) LEventCustom(eventType string, eventName string) *zerolog.Event
- func (c *Client) LEventF(eventType string, eventName string, functionName string) *zerolog.Event
- func (c *Client) LFatal() *zerolog.Event
- func (c *Client) LInfo() *zerolog.Event
- func (c *Client) LInfoF(functionName string) *zerolog.Event
- func (c *Client) LPanic() *zerolog.Event
- func (c *Client) LWarn() *zerolog.Event
- func (c *Client) LWarnF(functionName string) *zerolog.Event
- func (c *Client) OnBeforeConnectToServer(name string, callback OnBeforeConnectToServer) bool
- func (c *Client) OnBeforeConnectToServerRemove(name string)
- func (c *Client) OnBeforeDisconnect(name string, callback OnBeforeDisconnect) bool
- func (c *Client) OnBeforeDisconnectRemove(name string)
- func (c *Client) OnBinary(name string, callback OnBinary) bool
- func (c *Client) OnBinaryRemove(name string)
- func (c *Client) OnConnect(name string, callback OnConnect) bool
- func (c *Client) OnConnectError(name string, callback OnConnectError) bool
- func (c *Client) OnConnectErrorRemove(name string)
- func (c *Client) OnConnectFailed(name string, callback OnConnectFailed) bool
- func (c *Client) OnConnectFailedAll(name string, callback OnConnectFailedAll) bool
- func (c *Client) OnConnectFailedAllRemove(name string)
- func (c *Client) OnConnectFailedRemove(name string)
- func (c *Client) OnConnectRemove(name string)
- func (c *Client) OnConnectSuccess(name string, callback OnConnectSuccess) bool
- func (c *Client) OnConnectSuccessRemove(name string)
- func (c *Client) OnDisconnect(name string, callback OnDisconnect) bool
- func (c *Client) OnDisconnectRemove(name string)
- func (c *Client) OnError(name string, callback OnError) bool
- func (c *Client) OnErrorRemove(name string)
- func (c *Client) OnLinkDisconnect(name string, callback OnLinkDisconnect) bool
- func (c *Client) OnLinkDisconnectRemove(name string)
- func (c *Client) OnMessage(name string, callback OnReceive) bool
- func (c *Client) OnMessageRemove(name string)
- func (c *Client) OnReadError(name string, callback OnReadError) bool
- func (c *Client) OnReadErrorRemove(name string)
- func (c *Client) OnReceive(name string, callback OnReceive) bool
- func (c *Client) OnReceiveRemove(name string)
- func (c *Client) OnReconnectFailed(name string, callback OnReconnectFailed) bool
- func (c *Client) OnReconnectFailedRemove(name string)
- func (c *Client) OnReconnected(name string, callback OnReconnected) bool
- func (c *Client) OnReconnectedRemove(name string)
- func (c *Client) OnReconnecting(name string, callback OnReconnecting) bool
- func (c *Client) OnReconnectingRemove(name string)
- func (c *Client) OnSend(name string, callback OnSend) bool
- func (c *Client) OnSendError(name string, callback OnSendError) bool
- func (c *Client) OnSendErrorRemove(name string)
- func (c *Client) OnSendRemove(name string)
- func (c *Client) OnStopConnectingFinish(name string, callback OnStopConnectingFinish) bool
- func (c *Client) OnStopConnectingFinishRemove(name string)
- func (c *Client) OnTerminate(name string, callback OnTerminate) bool
- func (c *Client) OnTerminateRemove(name string)
- func (c *Client) OnText(name string, callback OnText) bool
- func (c *Client) OnTextRemove(name string)
- func (c *Client) Reconnect()
- func (c *Client) RemoveOnConnectSuccess(name string)
- func (c *Client) SendBinary()
- func (c *Client) SendText()
- func (c *Client) StopConnecting()
- func (c *Client) WriteBinary()
- func (c *Client) WriteText()
- type OnBeforeConnectToServer
- type OnBeforeDisconnect
- type OnBinary
- type OnConnect
- type OnConnectError
- type OnConnectErrorResponse
- type OnConnectFailed
- type OnConnectFailedAll
- type OnConnectSuccess
- type OnDisconnect
- type OnError
- type OnLinkDisconnect
- type OnReadError
- type OnReceive
- type OnReconnectFailed
- type OnReconnected
- type OnReconnecting
- type OnSend
- type OnSendError
- type OnStopConnectingFinish
- type OnTerminate
- type OnText
Constants ¶
This section is empty.
Variables ¶
var ConnectionFailedToHost = define.Err(300, "connection failed to host")
var NoConnectionsDefined = define.Err(400, "no connections have being defined")
var ReaderError = define.Err(200, "reader error")
var WriterError = define.Err(100, "writer error")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // RequestHeader -> can be configured directly RequestHeader http.Header // This is the Logger of the websocket client, we make it public, for easier interaction! Logger *model.Logger //Objects WSClient *websocket.Conn // This is the Gorilla Web Socket Client HttpResponse *http.Response // This is the response from the server! // contains filtered or unexported fields }
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
Disconnect -> It will send the disconnect packet, but it will not wait for it! Forcefully Stops the connection! This function can also be called by the user! to terminate the connection!
func (*Client) DisconnectGracefully ¶
DisconnectGracefully -> It will send the disconnect packet, but it will wait until it receives confirmation, and if it doesn't receives it, it will be refer to the timeout and other params configured on the client after everything has passed, it will disconnect
func (*Client) GetConnectedTo ¶
GetConnectedTo -> Where has being connected to
func (*Client) GetConnectingTo ¶
GetConnectingTo -> Where it's trying to connect to!
func (*Client) GetConnection ¶
func (c *Client) GetConnection(connectionNr int) *connection.Connection
func (*Client) GetConnections ¶
func (c *Client) GetConnections() []*connection.Connection
func (*Client) GetLatency ¶
func (c *Client) GetLatency()
func (*Client) HasOnConnectFailedAll ¶
func (*Client) HasOnConnectSuccess ¶
func (*Client) IsConnected ¶
IsConnected -> If is connected right now!
func (*Client) IsConnecting ¶
IsConnecting -> If is connecting right now!
func (*Client) LDebugF ¶
LDebugF -> when you need specifically to indicate in what function the logging is happening
func (*Client) LErrorF ¶
LErrorF -> when you need specifically to indicate in what function the logging is happening
func (*Client) LEventCustom ¶
func (*Client) LInfoF ¶
LInfoF -> when you need specifically to indicate in what function the logging is happening
func (*Client) LWarnF ¶
LWarnF -> when you need specifically to indicate in what function the logging is happening
func (*Client) OnBeforeConnectToServer ¶
func (c *Client) OnBeforeConnectToServer(name string, callback OnBeforeConnectToServer) bool
func (*Client) OnBeforeConnectToServerRemove ¶
func (*Client) OnBeforeDisconnect ¶
func (c *Client) OnBeforeDisconnect(name string, callback OnBeforeDisconnect) bool
func (*Client) OnBeforeDisconnectRemove ¶
func (*Client) OnBinaryRemove ¶
func (*Client) OnConnectError ¶
func (c *Client) OnConnectError(name string, callback OnConnectError) bool
func (*Client) OnConnectErrorRemove ¶
func (*Client) OnConnectFailed ¶
func (c *Client) OnConnectFailed(name string, callback OnConnectFailed) bool
func (*Client) OnConnectFailedAll ¶
func (c *Client) OnConnectFailedAll(name string, callback OnConnectFailedAll) bool
func (*Client) OnConnectFailedAllRemove ¶
func (*Client) OnConnectFailedRemove ¶
func (*Client) OnConnectRemove ¶
func (*Client) OnConnectSuccess ¶
func (c *Client) OnConnectSuccess(name string, callback OnConnectSuccess) bool
func (*Client) OnConnectSuccessRemove ¶
func (*Client) OnDisconnect ¶
func (c *Client) OnDisconnect(name string, callback OnDisconnect) bool
func (*Client) OnDisconnectRemove ¶
func (*Client) OnErrorRemove ¶
func (*Client) OnLinkDisconnect ¶
func (c *Client) OnLinkDisconnect(name string, callback OnLinkDisconnect) bool
func (*Client) OnLinkDisconnectRemove ¶
func (*Client) OnMessageRemove ¶
OnMessageRemove analog to OnReceiveRemove
func (*Client) OnReadError ¶
func (c *Client) OnReadError(name string, callback OnReadError) bool
func (*Client) OnReadErrorRemove ¶
func (*Client) OnReceiveRemove ¶
func (*Client) OnReconnectFailed ¶
func (c *Client) OnReconnectFailed(name string, callback OnReconnectFailed) bool
func (*Client) OnReconnectFailedRemove ¶
func (*Client) OnReconnected ¶
func (c *Client) OnReconnected(name string, callback OnReconnected) bool
func (*Client) OnReconnectedRemove ¶
func (*Client) OnReconnecting ¶
func (c *Client) OnReconnecting(name string, callback OnReconnecting) bool
func (*Client) OnReconnectingRemove ¶
func (*Client) OnSendError ¶
func (c *Client) OnSendError(name string, callback OnSendError) bool
func (*Client) OnSendErrorRemove ¶
func (*Client) OnSendRemove ¶
func (*Client) OnStopConnectingFinish ¶
func (c *Client) OnStopConnectingFinish(name string, callback OnStopConnectingFinish) bool
func (*Client) OnStopConnectingFinishRemove ¶
func (*Client) OnTerminate ¶
func (c *Client) OnTerminate(name string, callback OnTerminate) bool
func (*Client) OnTerminateRemove ¶
func (*Client) OnTextRemove ¶
func (*Client) Reconnect ¶
func (c *Client) Reconnect()
Reconnect -> it's initiating again the connection process but calling and other callbacks before it... The user can also call this function if handling manually or from other place this process! We have created this function to delimit the connect with reconnect as events, and for the user to know what's happened, and of course for easier understanding!
func (*Client) RemoveOnConnectSuccess ¶
func (*Client) SendBinary ¶
func (c *Client) SendBinary()
func (*Client) StopConnecting ¶
func (c *Client) StopConnecting()
StopConnecting -> Simply stop connecting
func (*Client) WriteBinary ¶
func (c *Client) WriteBinary()
type OnBeforeConnectToServer ¶
type OnBeforeConnectToServer func()
OnBeforeConnectToServer -> it's being called before each connection call
type OnBeforeDisconnect ¶
type OnBeforeDisconnect func()
type OnBinary ¶
type OnBinary func(recvMessage *server.ReceivedMessage, c *Client)
OnBinary -> when we receive a binary message
type OnConnectError ¶
type OnConnectError func(error)
OnConnectError -> it's being called when connection has failed to be initiated
type OnConnectErrorResponse ¶
type OnConnectErrorResponse struct { // Other details MaxRetries uint16 // how many retries will be RetryNr uint16 // the attempt // Error Details MainError error OriginalError error // Connection Details ConnectionNr uint16 Connection *connection.Connection }
OnConnectErrorResponse -> it's a response structure for OnConnectFailed
type OnConnectFailed ¶
type OnConnectFailed func(OnConnectErrorResponse)
OnConnectFailed -> It's being called each time when a connection has failed to connect
type OnConnectFailedAll ¶
type OnConnectFailedAll func()
OnConnectFailedAll -> it's being called When all connections have failed to connect!
type OnConnectSuccess ¶
type OnConnectSuccess func(connNr int, connection *connection.Connection)
OnConnectSuccess -> it's being called when the client has being connected successfully to the host
type OnDisconnect ¶
type OnDisconnect func()
type OnLinkDisconnect ¶
type OnLinkDisconnect func(connNr int, connection *connection.Connection)
OnLinkDisconnect -> When we have lost connection for a specific connection
type OnReadError ¶
type OnReadError func(error)
type OnReceive ¶
type OnReceive func(recvMessage *server.ReceivedMessage, c *Client)
OnReceive -> when we receive any message (text or binary)
type OnReconnectFailed ¶
type OnReconnectFailed func()
OnReconnectFailed -> When reconnection has totally failed and it has stopped... Usually if reconnect max retries has being set to -1 meaning infinite... this event will not occur!
type OnReconnected ¶
type OnReconnected func(connNr int, connection *connection.Connection)
OnReconnected -> it's being called when reconnection has being called, and the client has successfully connected to the host
type OnReconnecting ¶
type OnReconnecting func()
OnReconnecting -> it's being called when reconnect function it's being called!
type OnSendError ¶
type OnSendError func()
type OnStopConnectingFinish ¶
type OnStopConnectingFinish func()
OnStopConnectingFinish -> it's being used when stopConnecting function it's being called! And when the process of connecting is stopped and finished, this event it's being called
type OnTerminate ¶
type OnTerminate func()
OnTerminate -> it's being called when connection has being totally terminated or finalized
type OnText ¶
type OnText func(recvMessage *server.ReceivedMessage, c *Client)
OnText -> when we receive a text message