Documentation ¶
Index ¶
- Constants
- func GetMessageType(msg []byte) (id int8, err error)
- func Marshal(msg interface{}) (packBytes []byte, err error)
- func Unmarshal(b []byte, msg interface{}) error
- type BaseMessage
- type ClientConfig
- type ClientConfigure
- type Command
- type CommandData
- type CommandMessage
- type CommandStatus
- type Console
- type ConsoleState
- type Message
- func NewClientConfigure(config ClientConfig) Message
- func NewConsoleClose(sessionID string) Message
- func NewConsoleInput(sessionID string, in []byte) Message
- func NewConsoleOutput(sessionID string, in []byte) Message
- func NewConsoleStart(sessionID, shell string) Message
- func NewProxyRequest(serverID, id, sessionID, url string, req []byte) Message
- func NewProxyResponse(requestData ProxyData, res []byte) Message
- func NewTransferRequest(sessionID string, req TransferRequestData) Message
- func NewTransferResponse(data transferData, res []TransferResponseData) Message
- type Proxy
- type ProxyData
- type Transfer
- type TransferRequestData
- type TransferResponseData
Constants ¶
const ( // TransferActionPost is the action for post json or text to external service. TransferActionPost = "post" // TransferActionGet is the action for download file from external service. TransferActionGet = "get" )
const ( // TypeInvalid is type id for invalid type TypeInvalid int8 = 0000 // TypeNone is type id for BaseMessage TypeNone int8 = 0001 // TypeCommand is type id for CommandMessage TypeCommand int8 = 0010 // TypeRoutingConfigure is type id for RoutingConfigureMessage TypeRoutingConfigure int8 = 0020 // TypeClientConfigure is type id for ClientConfigureMessage TypeClientConfigure int8 = 0021 // TypeConsole is type id for Console TypeConsole int8 = 0040 // TypeProxy is type id for Proxy TypeProxy int8 = 0050 )
Variables ¶
This section is empty.
Functions ¶
func GetMessageType ¶
GetMessageType gets type for message by extended header in msgpack
Types ¶
type BaseMessage ¶
BaseMessage defines basic message.
func (*BaseMessage) GetMessageType ¶
func (m *BaseMessage) GetMessageType() string
GetMessageType returns message type property.
func (*BaseMessage) GetModel ¶
func (m *BaseMessage) GetModel() string
GetModel returns model property.
type ClientConfig ¶
type ClientConfig struct { PingInterval int `json:"ping_interval"` DeviceID string `json:"device_id"` }
ClientConfig defines data model for client basic setting.
type ClientConfigure ¶
type ClientConfigure struct { BaseMessage Data ClientConfig `json:"data"` }
ClientConfigure defines message for configuring client basic config.
type Command ¶
type Command struct { BaseMessage Data CommandData `json:"data"` }
Command defines message for command execution
func (*Command) SetStatus ¶
func (c *Command) SetStatus(status CommandStatus)
SetStatus set a status attribute to command message.
type CommandData ¶
type CommandData struct { ID string `json:"id"` DeviceID string `json:"device_id"` Status CommandStatus `json:"status"` Result string `json:"result"` Command string `json:"command"` }
CommandData defines data for command message
type CommandMessage ¶
type CommandMessage interface { Message SetStatus(status CommandStatus) SetResult(result string) }
CommandMessage defines interface for command message methods
func NewCommand ¶
func NewCommand(commandID, deviceID string, status CommandStatus, result, command string) CommandMessage
NewCommand creates command execution message
type CommandStatus ¶
type CommandStatus string
CommandStatus defines type of command message status
const ( // CommandExecutingStatus specifies the status of executing command in client. CommandExecutingStatus CommandStatus = "executing" // CommandErrorStatus specifies the status of command execution was failed. CommandErrorStatus CommandStatus = "error" // CommandExecutedStatus specifies the status of command execution was success. CommandExecutedStatus CommandStatus = "executed" )
type Console ¶
type Console struct { BaseMessage State ConsoleState `json:"state"` SessionID string `json:"session_id"` Data []byte `json:"data"` }
Console defines message for create console session between server and client.
type ConsoleState ¶
type ConsoleState string
ConsoleState defines type of console message state
const ( // ConsoleStartState is state of message of start console session to legs-client. ConsoleStartState ConsoleState = "start" // ConsoleInputState is state of message of input to legs-client console. ConsoleInputState ConsoleState = "input" // ConsoleCloseState is state of message of request for close console session. ConsoleCloseState ConsoleState = "close" // ConsoleOutputState is state of message of output from legs-client to server. ConsoleOutputState ConsoleState = "output" )
type Message ¶
Message defines interface for every message structs
func NewClientConfigure ¶
func NewClientConfigure(config ClientConfig) Message
NewClientConfigure creates client configure message.
func NewConsoleClose ¶
NewConsoleClose creates console message at close session.
func NewConsoleInput ¶
NewConsoleInput creates console message for input to client device.
func NewConsoleOutput ¶
NewConsoleOutput creates console message for output from client device.
func NewConsoleStart ¶
NewConsoleStart creates console message at start session
func NewProxyRequest ¶
NewProxyRequest creates instance of Proxy with request bytes
func NewProxyResponse ¶
NewProxyResponse creates instance of Proxy with response bytes
func NewTransferRequest ¶
func NewTransferRequest(sessionID string, req TransferRequestData) Message
NewTransferRequest creates a transfer request message from string url.
func NewTransferResponse ¶
func NewTransferResponse(data transferData, res []TransferResponseData) Message
NewTransferResponse creates a transfer response message from request data.
type Proxy ¶
type Proxy struct { BaseMessage Data ProxyData `json:"data"` }
Proxy defines message for url forwarding protocol.
func (*Proxy) SetResponse ¶
SetResponse set a response to proxy data
type ProxyData ¶
type ProxyData struct { ID string `json:"id"` URL string `json:"url"` Request []byte `json:"request"` Response []byte `json:"response"` ServerID string `json:"server_id"` SessionID string `json:"session_id"` }
ProxyData defines data for proxy message
type Transfer ¶
type Transfer struct { BaseMessage Data transferData `json:"data"` }
Transfer defines message for data transfer request using raw url.
type TransferRequestData ¶
type TransferRequestData struct { Action string `json:"action"` Target string `json:"target"` Value string `json:"value"` }
TransferRequestData defines request for http request transfer. Action: `TransferActionPost` or `TransferActionGet` Target: Transfer request destination. The Target can be a valid url (beginning with `http`) and routing name stored on the server. Value: The Request body for transfer http request.
type TransferResponseData ¶
type TransferResponseData struct { URL string `json:"url"` Body []byte `json:"body"` StatusCode int `json:"status_code"` }
TransferResponseData defines response when transferred http request. URL: transfer destination Body: http response body StatusCode: http response code