client

package
v0.0.0-...-471d7c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
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 NewClient

func NewClient() (*Client, error)

NewClient creates a new Client object.

func (*Client) Close

func (c *Client) Close() error

Close closes a client connection.

func (*Client) Connect

func (c *Client) Connect(addr string) error

Connect connectes to the server at given network address and starts receiving messages.

func (*Client) DisconnHandler

func (c *Client) DisconnHandler(handler func(c *Client))

DisconnHandler registers a function to handle disconnection event.

func (*Client) Echo

func (c *Client) Echo(m interface{}, msgHandler func(msg *models.Message) error) error

Echo sends a message to server echo endpoint. This is meant to be used for testing connectivity.

func (*Client) GoogleAuth

func (c *Client) GoogleAuth(oauthToken string, handler func(jwtToken string) error) error

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

func (c *Client) InMsgHandler(handler func(m []models.Message) error)

InMsgHandler registers a handler to accept incoming messages from the server.

func (*Client) JWTAuth

func (c *Client) JWTAuth(jwtToken string, handler func(ack string) error) error

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

func (c *Client) MiddlewareFunc(middleware ...func(ctx *neptulon.ReqCtx) error)

MiddlewareFunc registers middleware function to handle incoming request messages.

func (*Client) SendMessages

func (c *Client) SendMessages(m []models.Message, handler func(ack string) error) error

SendMessages sends a batch of messages to the server.

func (*Client) SetDeadline

func (c *Client) SetDeadline(seconds int)

SetDeadline set the read/write deadlines for the connection, in seconds.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL