gate_client

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: MIT Imports: 20 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 {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGateClient

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

func (*GateClient) AddMobile

func (g *GateClient) AddMobile(ctx context.Context) (list *MobileList, err error)

func (*GateClient) Broadcast added in v0.0.15

func (g *GateClient) Broadcast(message []byte)

func (*GateClient) BroadcastAccessToken added in v0.0.13

func (g *GateClient) BroadcastAccessToken()

func (*GateClient) Close

func (g *GateClient) Close()

func (*GateClient) Connect

func (g *GateClient) Connect()

func (*GateClient) DeleteMobile

func (g *GateClient) DeleteMobile(token string, ctx context.Context) (list *MobileList, err error)

func (*GateClient) GetMobileList

func (g *GateClient) GetMobileList(ctx context.Context) (list *MobileList, err error)

func (*GateClient) GetSettings

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

func (*GateClient) LoadSettings

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

func (*GateClient) RegisterServer added in v0.0.13

func (g *GateClient) RegisterServer()

func (*GateClient) RequestFromMobileProxy added in v0.0.11

func (g *GateClient) RequestFromMobileProxy(message Message)

func (*GateClient) Restart added in v0.0.13

func (g *GateClient) Restart()

func (*GateClient) SaveSettings

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

func (*GateClient) Send

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

func (*GateClient) SetEngine added in v0.0.11

func (g *GateClient) SetEngine(engine *gin.Engine)

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 StreamRequestModel added in v0.0.11

type StreamRequestModel struct {
	URI    string      `json:"uri"`
	Method string      `json:"method"`
	Body   []byte      `json:"body"`
	Header http.Header `json:"header"`
}

type StreamResponseModel added in v0.0.11

type StreamResponseModel struct {
	Code   int         `json:"code"`
	Body   []byte      `json:"body"`
	Header http.Header `json:"header"`
}

type WsClient

type WsClient struct {
	sync.Mutex
	// 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