Client is the client for communicating with another Kite. It has Tell() and Go() methods for calling methods sync/async way.

Client is referenced in 3 repositories


type Client struct {
	// The information about the kite that we are connecting to.
	muProt sync.Mutex // protects protocol.Kite access

	// A reference to the current Kite running.
	LocalKite *Kite

	// Credentials that we sent in each request.
	Auth *Auth

	// Should we reconnect if disconnected?
	Reconnect bool

	// SockJS base URL
	URL string

	// Should we process incoming messages concurrently or not? Default: true
	Concurrent bool

	// ConcurrentCallbacks, when true, makes execution of callbacks in
	// incoming messages concurrent. This may result in a callback
	// received in an earlier message to be executed after a callback
	// from a new meesage - no order is guaranteed, it's up to Go scheduler.
	// By default this field is false to be backward-compatible with
	// go1.4 scheduling behaviour.
	ConcurrentCallbacks bool

	// ClientFunc is called each time new sockjs.Session is established.
	// The session will use returned *http.Client for HTTP round trips
	// for XHR transport.
	// If ClientFunc is nil, sockjs.Session will use default, internal
	// *http.Client value.
	ClientFunc func(*sockjsclient.DialOptions) *http.Client

	// To signal waiters of Go() on disconnect.
	disconnect   chan struct{}
	disconnectMu sync.Mutex // protects disconnect chan

	// authMu protects Auth field.
	authMu sync.Mutex

	// To signal about the close
	closeChan chan struct{}

	// To syncronize the consumers
	wg *sync.WaitGroup

	// SockJS session
	// TODO: replace this with a proper interface to support multiple
	// transport/protocols
	session sockjs.Session
	send    chan *message

	// muReconnect protects Reconnect
	muReconnect sync.Mutex

	// closed is to ensure Close is idempotent
	closed int32

	// dnode scrubber for saving callbacks sent to remote.
	scrubber *dnode.Scrubber

	// Time to wait before redial connection.
	redialBackOff backoff.ExponentialBackOff

	// on connect/disconnect handlers are invoked after every
	// connect/disconnect.
	onConnectHandlers     []func()
	onDisconnectHandlers  []func()
	onTokenExpireHandlers []func()
	onTokenRenewHandlers  []func(string)

	testHookSetSession func(sockjs.Session)

	// For protecting access over OnConnect and OnDisconnect handlers.
	m sync.RWMutex

	firstRequestHandlersNotified sync.Once

	// ReadBufferSize is the input buffer size. By default it's 4096.
	ReadBufferSize int

	// WriteBufferSize is the output buffer size. By default it's 4096.
	WriteBufferSize int