Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(addr string) error
- func (c *Client) DisconnHandler(handler func(c *Client))
- func (c *Client) Echo(m interface{}, msgHandler func(msg *models.Message) error) error
- func (c *Client) GoogleAuth(oauthToken string, handler func(jwtToken string) error) error
- func (c *Client) InMsgHandler(handler func(m []models.Message) error)
- func (c *Client) JWTAuth(jwtToken string, handler func(ack string) error) error
- func (c *Client) Middleware(middleware ...neptulon.Middleware)
- func (c *Client) MiddlewareFunc(middleware ...func(ctx *neptulon.ReqCtx) error)
- func (c *Client) SendMessages(m []models.Message, handler func(ack string) error) error
- func (c *Client) SetDeadline(seconds int)
Constants ¶
const ( // ACK is the short acknowledgement response for a request. ACK = "ACK" // NACK is the short rejection response for a request. NACK = "NACK" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ID string // Randomly generated unique client connection ID. Session *cmap.CMap // Thread-safe data store for storing arbitrary data for this connection session. // contains filtered or unexported fields }
Client is a Titan client.
func (*Client) Connect ¶
Connect connectes to the server at given network address and starts receiving messages.
func (*Client) DisconnHandler ¶
DisconnHandler registers a function to handle disconnection event.
func (*Client) Echo ¶
Echo sends a message to server echo endpoint. This is meant to be used for testing connectivity.
func (*Client) GoogleAuth ¶
GoogleAuth authenticates using the given Google OAuth token and retrieves a JWT token. This also announces availability to the server, so server can start sending us pending messages.
func (*Client) InMsgHandler ¶
InMsgHandler registers a handler to accept incoming messages from the server.
func (*Client) JWTAuth ¶
JWTAuth authenticates using the given JWT token. This also announces availability to the server, so server can start sending us pending messages.
func (*Client) Middleware ¶
func (c *Client) Middleware(middleware ...neptulon.Middleware)
Middleware registers middleware to handle incoming request messages.
func (*Client) MiddlewareFunc ¶
MiddlewareFunc registers middleware function to handle incoming request messages.
func (*Client) SendMessages ¶
SendMessages sends a batch of messages to the server.
func (*Client) SetDeadline ¶
SetDeadline set the read/write deadlines for the connection, in seconds.