client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Write(res *model.Message)
	Read(cb DataCallback)
	RoutineWrite()
	ClientID() string
	Close()
	Context() context.Context
}

Client is the inteface for the websocket and grpc sockets

type DataCallback

type DataCallback func(data *model.Message) bool

DataCallback is the callback invoked when data is read by the socket

type WebsocketClient

type WebsocketClient struct {
	// contains filtered or unexported fields
}

WebsocketClient is the websocket client

func CreateWebsocketClient

func CreateWebsocketClient(socket *websocket.Conn) *WebsocketClient

CreateWebsocketClient makes a client object to manage the socket

func (*WebsocketClient) ClientID

func (c *WebsocketClient) ClientID() string

ClientID returns the client's id

func (*WebsocketClient) Close

func (c *WebsocketClient) Close()

Close closes the client

func (*WebsocketClient) Context

func (c *WebsocketClient) Context() context.Context

Context returns the client's context

func (*WebsocketClient) Read

func (c *WebsocketClient) Read(cb DataCallback)

Read starts a blocking reader routine

func (*WebsocketClient) RoutineWrite

func (c *WebsocketClient) RoutineWrite()

RoutineWrite starts a json writer routine

func (*WebsocketClient) Write

func (c *WebsocketClient) Write(res *model.Message)

Write writes the object to the client

Jump to

Keyboard shortcuts

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