gate_client

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Request       = "request"
	Response      = "response"
	StatusSuccess = "success"
	StatusError   = "error"
)
View Source
const (
	GateStatusWait      = "wait"
	GateStatusDisabled  = "disabled"
	GateStatusConnected = "connected"
)
View Source
const (
	ClientTypeServer = "server"
)

Variables

View Source
var (
	ErrGateNotConnected = fmt.Errorf("gate not connected")
)

Functions

This section is empty.

Types

type GateClient

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

func NewGateClient

func NewGateClient(adaptors *adaptors.Adaptors,
	graceful *graceful_service.GracefulService) (gate *GateClient)

func (*GateClient) AddMobile

func (g *GateClient) AddMobile() (list *MobileList, err error)

func (*GateClient) Close

func (g *GateClient) Close()

func (*GateClient) Connect

func (g *GateClient) Connect()

func (*GateClient) DeleteMobile

func (g *GateClient) DeleteMobile(token string) (list *MobileList, err error)

func (*GateClient) GetMobileList

func (g *GateClient) GetMobileList() (list *MobileList, err error)

func (*GateClient) GetSettings

func (g *GateClient) GetSettings() (*Settings, error)

func (*GateClient) LoadSettings

func (g *GateClient) LoadSettings() (err error)

func (*GateClient) SaveSettings

func (g *GateClient) SaveSettings() (err error)

func (*GateClient) Send

func (g *GateClient) Send(command string, payload map[string]interface{}, f func(msg Message)) (err error)

func (*GateClient) Shutdown

func (g *GateClient) Shutdown()

func (*GateClient) Status

func (g *GateClient) Status() string

func (*GateClient) Subscribe

func (g *GateClient) Subscribe(id uuid.UUID, f func(msg Message))

func (*GateClient) UnSubscribe

func (g *GateClient) UnSubscribe(id uuid.UUID)

func (*GateClient) UpdateSettings

func (g *GateClient) UpdateSettings(settings *Settings) (err error)

type IWsCallback

type IWsCallback interface {
	// contains filtered or unexported methods
}

type Message

type Message struct {
	Id      uuid.UUID              `json:"id"`
	Command string                 `json:"command"`
	Payload map[string]interface{} `json:"payload"`
	Forward string                 `json:"forward"`
	Status  string                 `json:"status"`
}

func NewMessage

func NewMessage(b []byte) (message Message, err error)

func (*Message) Error

func (m *Message) Error(err error) *Message

func (*Message) IsError

func (m *Message) IsError() (err error)

func (*Message) Pack

func (m *Message) Pack() []byte

func (*Message) Response

func (m *Message) Response(payload map[string]interface{}) *Message

func (*Message) Success

func (m *Message) Success() *Message

type MobileList

type MobileList struct {
	Total     int64    `json:"total"`
	TokenList []string `json:"token_list"`
}

type Settings

type Settings struct {
	GateServerToken string `json:"gate_server_token"`
	Address         string `json:"address"`
	Enabled         bool   `json:"enabled"`
}

func (Settings) Valid

func (s Settings) Valid() bool

type WsClient

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

func NewWsClient

func NewWsClient(adaptors *adaptors.Adaptors,
	cb IWsCallback) *WsClient

func (*WsClient) Close

func (client *WsClient) Close()

func (*WsClient) Connect

func (client *WsClient) Connect(settings *Settings)

Jump to

Keyboard shortcuts

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