Documentation ¶
Index ¶
- Constants
- Variables
- func ClientStatusText(status ClientStatus) string
- func JSONDecode(jsonmap map[string]any, dest any) error
- type BoolThreadSafe
- type ClientState
- type ClientStatus
- type ClientStatusThreadSafe
- type ConfigElementStruct
- type ConnNotifyEventFunc
- type DataNotifyEventFunc
- type DeviceStruct
- type EMalformedKind
- type EmptyNotifyFunc
- type ErrAuth
- type ErrBadResponse
- type ErrEmptyResponse
- type ErrHttpStatus
- type ErrLockedConfig
- type ErrMalformedResponse
- type ErrNotStreaming
- type ErrParam
- type ErrWrongArgument
- type ErrWrongAuthData
- type ErrWrongConfigElementFormat
- type ErrWrongHostName
- type ErrWrongOutMsgFormat
- type ErrWrongStatus
- type FramesListThreadSafe
- type ITask
- type InStream
- type JSONArrayNotifyEventFunc
- type JSONNotifyEventFunc
- type MediaMetaStruct
- type MediaStruct
- type MessageStruct
- type NotifyEventFunc
- type OutConfigElementStruct
- type OutMessageStruct
- type OutStream
- type StreamStruct
- type StringListThreadSafe
- type StringNotifyFunc
- type StringThreadSafe
- type Task
- type TaskKind
- type TaskNotifyFunc
- type WCClient
- func (c *WCClient) AddLog(aStr string)
- func (c *WCClient) Auth(aLogin, aPwrd string) error
- func (c *WCClient) AuthFromHostUrl() error
- func (c *WCClient) ClearError()
- func (c *WCClient) ClearLog()
- func (c *WCClient) DeleteRecords(aIndices []int, callback ...any) error
- func (c *WCClient) Disconnect() error
- func (c *WCClient) GetClientStatus() ClientStatus
- func (c *WCClient) GetConfig(callback ...any) error
- func (c *WCClient) GetLog() *StringListThreadSafe
- func (c *WCClient) GetLstMsgStamp() string
- func (c *WCClient) GetLstRecStamp() string
- func (c *WCClient) GetSID() string
- func (c *WCClient) InvalidateState(aStateId ClientState, callback ...any) error
- func (c *WCClient) IsClientStatusInRange(st []ClientStatus) bool
- func (c *WCClient) LastError() string
- func (c *WCClient) LaunchInStream(aDeviceName string, onNewFrame TaskNotifyFunc, userdata ...any) error
- func (c *WCClient) LaunchOutStream(aSubProto string, aDelta int, userdata ...any) error
- func (c *WCClient) PopInFrame() (*bytes.Buffer, error)
- func (c *WCClient) PushOutData(data *bytes.Buffer) error
- func (c *WCClient) RequestRecord(rid int, userdata ...any) error
- func (c *WCClient) RequestRecordMeta(rid int, callback ...any) error
- func (c *WCClient) SaveRecord(aBuf io.ReadCloser, aBufSize int64, meta string, callback ...any) error
- func (c *WCClient) SendMsgs(aMsg any, callback ...any) error
- func (c *WCClient) SetConfig(aStr []any, callback ...any) error
- func (c *WCClient) SetLstMsgStamp(value string)
- func (c *WCClient) SetLstMsgStampToSyncPoint()
- func (c *WCClient) SetLstRecStamp(value string)
- func (c *WCClient) SetNeedToSync(val bool)
- func (c *WCClient) SetOnAddLog(event StringNotifyFunc)
- func (c *WCClient) SetOnAfterLaunchInStream(event TaskNotifyFunc)
- func (c *WCClient) SetOnAfterLaunchOutStream(event TaskNotifyFunc)
- func (c *WCClient) SetOnAuthSuccess(event TaskNotifyFunc)
- func (c *WCClient) SetOnConnected(event ConnNotifyEventFunc)
- func (c *WCClient) SetOnDisconnect(event NotifyEventFunc)
- func (c *WCClient) SetOnGetConfig(event JSONArrayNotifyEventFunc)
- func (c *WCClient) SetOnReqRecordData(event DataNotifyEventFunc)
- func (c *WCClient) SetOnReqRecordMeta(event JSONNotifyEventFunc)
- func (c *WCClient) SetOnSetConfig(event TaskNotifyFunc)
- func (c *WCClient) SetOnSuccessDeleteRecords(event TaskNotifyFunc)
- func (c *WCClient) SetOnSuccessIOStream(event TaskNotifyFunc)
- func (c *WCClient) SetOnSuccessSaveRecord(event TaskNotifyFunc)
- func (c *WCClient) SetOnSuccessSendMsg(event TaskNotifyFunc)
- func (c *WCClient) SetOnUpdateDevices(event JSONArrayNotifyEventFunc)
- func (c *WCClient) SetOnUpdateMsgs(event JSONArrayNotifyEventFunc)
- func (c *WCClient) SetOnUpdateRecords(event JSONArrayNotifyEventFunc)
- func (c *WCClient) SetOnUpdateStreams(event JSONArrayNotifyEventFunc)
- func (c *WCClient) SetSIDSetted(event StringNotifyFunc)
- func (c *WCClient) Start() error
- func (c *WCClient) StopStreaming()
- func (c *WCClient) UpdateDevices(callback ...any) error
- func (c *WCClient) UpdateMsgs(callback ...any) error
- func (c *WCClient) UpdateRecords(callback ...any) error
- func (c *WCClient) UpdateStreams(callback ...any) error
- func (c *WCClient) Working() bool
- type WCClientConfig
- func (c *WCClientConfig) AssignFrom(src *WCClientConfig) error
- func (c *WCClientConfig) GetDevice() string
- func (c *WCClientConfig) GetHost() string
- func (c *WCClientConfig) GetMeta() string
- func (c *WCClientConfig) GetPort() int
- func (c *WCClientConfig) GetUrl(command string) string
- func (c *WCClientConfig) GetVerifyTLS() bool
- func (c *WCClientConfig) SetDevice(device string) error
- func (c *WCClientConfig) SetHostURL(hosturl string) error
- func (c *WCClientConfig) SetMeta(val string) error
- func (c *WCClientConfig) SetPort(port int) error
- func (c *WCClientConfig) SetProxy(proxy string) error
- func (c *WCClientConfig) SetVerifyTLS(sec bool) error
Constants ¶
const DATABASE_FAIL = 3
const EMPTY_REQUEST = 11
const ERRORED_STREAM = 14
const INTERNAL_UNKNOWN_ERROR = 2
const JSON_FAIL = 5
const JSON_PARSER_FAIL = 4
const JSON_RPC_BAD string = "BAD"
const JSON_RPC_CODE string = "code"
const JSON_RPC_CONFIG string = "config"
const JSON_RPC_DELTA string = "delta"
const JSON_RPC_DESCR string = "descr"
const JSON_RPC_DEVICE string = "device"
const JSON_RPC_DEVICES string = "devices"
const JSON_RPC_DV string = "dv"
const JSON_RPC_FV string = "fv"
const JSON_RPC_KIND string = "kind"
const JSON_RPC_MAV string = "mav"
const JSON_RPC_META string = "meta"
const JSON_RPC_MID string = "mid"
const JSON_RPC_MIV string = "miv"
const JSON_RPC_MSG string = "msg"
const JSON_RPC_MSGS string = "msgs"
const JSON_RPC_NAME string = "name"
const JSON_RPC_OK string = "OK"
const JSON_RPC_PARAMS string = "params"
const JSON_RPC_PASS string = "pass"
const JSON_RPC_RECORDS string = "records"
const JSON_RPC_RESULT string = "result"
const JSON_RPC_RID string = "rid"
const JSON_RPC_SHASH string = "shash"
const JSON_RPC_STAMP string = "stamp"
const JSON_RPC_SUBPROTO string = "subproto"
const JSON_RPC_SYNC string = "sync"
const JSON_RPC_TARGET string = "target"
const MALFORMED_REQUEST = 12
const NO_CHANNEL = 13
const NO_DATA_RETURNED = 10
const NO_DEVICES_ONLINE = 8
const NO_ERROR = 0
const NO_SUCH_DEVICE = 15
const NO_SUCH_RECORD = 9
const NO_SUCH_SESSION = 6
const NO_SUCH_USER = 7
const REST_SYNC_MSG string = "{\"msg\":\"sync\"}"
const UNSPECIFIED = 1
const WC_FRAME_BUFFER_INIT_SIZE int64 = 4096
The initial frame buffer size
const WC_FRAME_BUFFER_SIZE int64 = 0x200000
The frame buffer size (the maximum size of one frame)
const WC_FRAME_START_SEQ uint16 = 0xaaaa
The frame header sequence
const WC_STREAM_FRAME_HEADER_SIZE uint16 = 6
The size of frame header (6 bytes)
Variables ¶
var RESPONSE_ERRORS = [...]string{
"NO_ERROR",
"UNSPECIFIED",
"INTERNAL_UNKNOWN_ERROR",
"DATABASE_FAIL",
"JSON_PARSER_FAIL",
"JSON_FAIL",
"NO_SUCH_SESSION",
"NO_SUCH_USER",
"NO_DEVICES_ONLINE",
"NO_SUCH_RECORD",
"NO_DATA_RETURNED",
"EMPTY_REQUEST",
"MALFORMED_REQUEST",
"NO_CHANNEL",
"ERRORED_STREAM",
"NO_SUCH_DEVICE"}
Functions ¶
func ClientStatusText ¶
func ClientStatusText(status ClientStatus) string
func JSONDecode ¶
You can use JSONHelper methods to convert json maps to structs. The methods are not efficient and applyable only for testing proposes. You can use other external suitable modules to work with JSON maps and convert to structs vise versa
Types ¶
type BoolThreadSafe ¶
type BoolThreadSafe struct { Value bool // contains filtered or unexported fields }
func (*BoolThreadSafe) GetValue ¶
func (c *BoolThreadSafe) GetValue() bool
func (*BoolThreadSafe) SetValue ¶
func (c *BoolThreadSafe) SetValue(val bool) bool
type ClientState ¶
type ClientState int
const STATE_CONFIG ClientState = 23
const STATE_CONNECTION ClientState = 0
const STATE_DEVICENAME ClientState = 12
const STATE_DEVICES ClientState = 6
const STATE_ERROR ClientState = 2
const STATE_HOSTNAME ClientState = 14
const STATE_LOG ClientState = 3
const STATE_METADATA ClientState = 11
const STATE_MSGS ClientState = 9
const STATE_MSGSSTAMP ClientState = 10
const STATE_PROXY ClientState = 15
const STATE_PROXYAUTH ClientState = 16
const STATE_PROXYHOST ClientState = 18
const STATE_PROXYPORT ClientState = 19
const STATE_PROXYPROTOCOL ClientState = 17
const STATE_PROXYPWRD ClientState = 21
const STATE_PROXYUSER ClientState = 20
const STATE_RECORDS ClientState = 7
const STATE_RECORDSSTAMP ClientState = 8
const STATE_SENDWITHSYNC ClientState = 22
const STATE_SID ClientState = 13
const STATE_STREAMING ClientState = 4
const STATE_STREAMS ClientState = 5
const STATE_VERIFYTLS ClientState = 1
type ClientStatus ¶
type ClientStatus int
const ( StateWaiting ClientStatus = iota StateConnectedWrongSID StateConnectedAuthorization StateConnected StateDisconnected )
type ClientStatusThreadSafe ¶
type ClientStatusThreadSafe struct {
// contains filtered or unexported fields
}
type ConfigElementStruct ¶
type ConfigElementStruct struct { Kind float64 `json:"kind"` Description string `json:"descr"` MinValue float64 `json:"miv"` MaxValue float64 `json:"mav"` DefaultValue float64 `json:"dv"` CurValue float64 `json:"fv"` }
func (*ConfigElementStruct) JSONDecode ¶
func (mr *ConfigElementStruct) JSONDecode(jsonmap map[string]any) error
Convert the golang map of any to the ConfigElementStruct
type ConnNotifyEventFunc ¶
type ConnNotifyEventFunc func(client *WCClient, status ClientStatus)
type DataNotifyEventFunc ¶
type DeviceStruct ¶
func (*DeviceStruct) JSONDecode ¶
func (mr *DeviceStruct) JSONDecode(jsonmap map[string]any) error
Convert the golang map of any to the DeviceStruct
type EMalformedKind ¶
type EMalformedKind int
const ( EMKWrongType EMalformedKind = iota EMKFieldExpected EMKUnexpectedValue )
type EmptyNotifyFunc ¶
type EmptyNotifyFunc func(client *WCClient)
type ErrBadResponse ¶
type ErrBadResponse struct {
// contains filtered or unexported fields
}
func ThrowErrBadResponse ¶
func ThrowErrBadResponse(code int) *ErrBadResponse
func (*ErrBadResponse) Error ¶
func (e *ErrBadResponse) Error() string
type ErrEmptyResponse ¶
type ErrEmptyResponse struct{}
func ThrowErrEmptyResponse ¶
func ThrowErrEmptyResponse() *ErrEmptyResponse
func (*ErrEmptyResponse) Error ¶
func (*ErrEmptyResponse) Error() string
type ErrHttpStatus ¶
type ErrHttpStatus struct {
// contains filtered or unexported fields
}
func ThrowErrHttpStatus ¶
func ThrowErrHttpStatus(status int) *ErrHttpStatus
func (*ErrHttpStatus) Error ¶
func (e *ErrHttpStatus) Error() string
type ErrLockedConfig ¶
type ErrLockedConfig struct{}
func ThrowErrLockedConfig ¶
func ThrowErrLockedConfig() *ErrLockedConfig
func (*ErrLockedConfig) Error ¶
func (e *ErrLockedConfig) Error() string
type ErrMalformedResponse ¶
type ErrMalformedResponse struct {
// contains filtered or unexported fields
}
func ThrowErrMalformedResponse ¶
func ThrowErrMalformedResponse(kind EMalformedKind, arg string, par any) *ErrMalformedResponse
func (*ErrMalformedResponse) Error ¶
func (e *ErrMalformedResponse) Error() string
type ErrNotStreaming ¶
type ErrNotStreaming struct{}
func ThrowErrNotStreaming ¶
func ThrowErrNotStreaming() *ErrNotStreaming
func (*ErrNotStreaming) Error ¶
func (e *ErrNotStreaming) Error() string
type ErrParam ¶
type ErrParam struct {
// contains filtered or unexported fields
}
func ThrowErrParam ¶
type ErrWrongArgument ¶
type ErrWrongArgument struct {
// contains filtered or unexported fields
}
func ThrowErrWrongArgument ¶
func ThrowErrWrongArgument(name string, value any) *ErrWrongArgument
func (*ErrWrongArgument) Error ¶
func (e *ErrWrongArgument) Error() string
type ErrWrongAuthData ¶
type ErrWrongAuthData struct{}
func ThrowErrWrongAuthData ¶
func ThrowErrWrongAuthData() *ErrWrongAuthData
func (*ErrWrongAuthData) Error ¶
func (e *ErrWrongAuthData) Error() string
type ErrWrongConfigElementFormat ¶
type ErrWrongConfigElementFormat struct{}
func ThrowErrWrongConfigElementFormat ¶
func ThrowErrWrongConfigElementFormat() *ErrWrongConfigElementFormat
func (*ErrWrongConfigElementFormat) Error ¶
func (e *ErrWrongConfigElementFormat) Error() string
type ErrWrongHostName ¶
type ErrWrongHostName struct {
// contains filtered or unexported fields
}
func ThrowErrWrongHostName ¶
func ThrowErrWrongHostName(url string) *ErrWrongHostName
func (*ErrWrongHostName) Error ¶
func (e *ErrWrongHostName) Error() string
type ErrWrongOutMsgFormat ¶
type ErrWrongOutMsgFormat struct{}
func ThrowErrWrongOutMsgFormat ¶
func ThrowErrWrongOutMsgFormat() *ErrWrongOutMsgFormat
func (*ErrWrongOutMsgFormat) Error ¶
func (e *ErrWrongOutMsgFormat) Error() string
type ErrWrongStatus ¶
type ErrWrongStatus struct {
// contains filtered or unexported fields
}
func ThrowErrWrongStatus ¶
func ThrowErrWrongStatus(status ClientStatus) *ErrWrongStatus
func (*ErrWrongStatus) Error ¶
func (e *ErrWrongStatus) Error() string
type FramesListThreadSafe ¶
type FramesListThreadSafe struct {
// contains filtered or unexported fields
}
func (*FramesListThreadSafe) Clear ¶
func (c *FramesListThreadSafe) Clear()
func (*FramesListThreadSafe) NotEmpty ¶
func (c *FramesListThreadSafe) NotEmpty() bool
func (*FramesListThreadSafe) Pop ¶
func (c *FramesListThreadSafe) Pop() *bytes.Buffer
func (*FramesListThreadSafe) PushBack ¶
func (c *FramesListThreadSafe) PushBack(str *bytes.Buffer)
type JSONNotifyEventFunc ¶
type MediaMetaStruct ¶
type MediaMetaStruct struct { Device string `json:"device"` Meta string `json:"meta"` Stamp string `json:"stamp"` }
func (*MediaMetaStruct) JSONDecode ¶
func (mr *MediaMetaStruct) JSONDecode(jsonmap map[string]any) error
Convert the golang map of any to the MediaMetaStruct
type MediaStruct ¶
type MediaStruct struct { Device string `json:"device"` Rid float64 `json:"rid"` Stamp string `json:"stamp"` }
func (*MediaStruct) JSONDecode ¶
func (mr *MediaStruct) JSONDecode(jsonmap map[string]any) error
Convert the golang map of any to the MediaStruct
type MessageStruct ¶
type MessageStruct struct { Device string `json:"device"` Msg string `json:"msg"` Stamp string `json:"stamp"` Params map[string]any `json:"params"` }
func (*MessageStruct) JSONDecode ¶
func (mr *MessageStruct) JSONDecode(jsonmap map[string]any) error
Convert the golang map of any to the MessageStruct
type NotifyEventFunc ¶
type OutConfigElementStruct ¶
func (*OutConfigElementStruct) JSONDecode ¶
func (mr *OutConfigElementStruct) JSONDecode(jsonmap map[string]any) error
Convert the golang map of any to the OutConfigElementStruct
type OutMessageStruct ¶
type StreamStruct ¶
type StreamStruct struct { Device string `json:"device"` SubProto string `json:"subproto"` Delta float64 `json:"delta"` }
func (*StreamStruct) JSONDecode ¶
func (mr *StreamStruct) JSONDecode(jsonmap map[string]any) error
Convert the golang map of any to the StreamStruct
type StringListThreadSafe ¶
type StringListThreadSafe struct {
// contains filtered or unexported fields
}
func (*StringListThreadSafe) Clear ¶
func (c *StringListThreadSafe) Clear()
func (*StringListThreadSafe) NotEmpty ¶
func (c *StringListThreadSafe) NotEmpty() bool
func (*StringListThreadSafe) PopFromLog ¶
func (c *StringListThreadSafe) PopFromLog() string
func (*StringListThreadSafe) PushBack ¶
func (c *StringListThreadSafe) PushBack(str string)
type StringNotifyFunc ¶
type StringThreadSafe ¶
type StringThreadSafe struct { Value string // contains filtered or unexported fields }
func (*StringThreadSafe) Clear ¶
func (c *StringThreadSafe) Clear()
func (*StringThreadSafe) GetValue ¶
func (c *StringThreadSafe) GetValue() string
func (*StringThreadSafe) GetValueUnsafePtr ¶
func (c *StringThreadSafe) GetValueUnsafePtr() *string
func (*StringThreadSafe) SetValue ¶
func (c *StringThreadSafe) SetValue(str string) bool
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
func (*Task) GetLastError ¶
func (*Task) GetUserData ¶
type TaskNotifyFunc ¶
type TaskNotifyFunc func(tsk ITask)
type WCClient ¶
type WCClient struct {
// contains filtered or unexported fields
}
func ClientNew ¶
func ClientNew(cfg *WCClientConfig) (*WCClient, error)
Create client.
`cfg` is a complete configuration for the client. `return` pointer to the new client instance and the error object.
func (*WCClient) Auth ¶
Launch request to authorize the client on the server host.
See protocol request `authorize.json`. If the specified `aLogin` or `aPwrd` are empty strings, the client tries to connect to the host using the username section from the host URL (\sa SetHostURL) `aLogin` is the name of the user on the server. `aPwrd` is the password of the user on the server. `return` nil on success or the error object.
func (*WCClient) AuthFromHostUrl ¶
Launch request to authorize the client on the server host.
See protocol request `authorize.json`. Username and password are parsed from the host URL (\sa SetHostURL) `return` nil on success or the error object.
func (*WCClient) DeleteRecords ¶
Delete specified media records for authorized client (see also `deleteRecords.json`).
`aIndices` is the array filled with the IDs of the records to be deleted The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnSuccessDeleteRecords method). The `callback` can be passed as: 1. a pair of values - a callback (TaskNotifyFunc) and user data (any) 2. just a reference to a callback of type TaskNotifyFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) Disconnect ¶
Disconnect client from the server host.
`return` nil on success or error object.
func (*WCClient) GetClientStatus ¶
func (c *WCClient) GetClientStatus() ClientStatus
Get the current status for the client
func (*WCClient) GetConfig ¶
Get configuration from the server for authorized client (sa `getConfig.json` request).
The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnGetConfig method). The `callback` can be passed as: 1. a pair of values - a callback (JSONArrayNotifyEventFunc) and user data (any) 2. just a reference to a callback of type JSONArrayNotifyEventFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) GetLstMsgStamp ¶
The timestamp of the last received message
func (*WCClient) GetLstRecStamp ¶
The timestamp of the last received media record
func (*WCClient) InvalidateState ¶
func (c *WCClient) InvalidateState(aStateId ClientState, callback ...any) error
Reset the selected client state.
Acceptable values of the state param are: STATE_LOG - clear the log, STATE_ERROR - delete information about the last error, STATE_DEVICES - update the list of devices (see also `getDevicesOnline.json`), STATE_RECORDS - update the list of media records (see also `getRecordCount.json` - according to the results of the request, the STATE_RECORDSSTAMP state will be updated automatically), STATE_RECORDSSTAMP - clear the timestamp for records (the *stamp* parameter in `getRecordCount.json` request), STATE_MSGS - update the list of messages (see also `getMsgs.json` - according to the results of the request, the STATE_MSGSSTAMP state will be updated automatically), STATE_SENDWITHSYNC - uncheck the synchronization flag - the next update of the message list will occur without the sending of a 'sync' message (`getMsgsAndSync.json`), STATE_MSGSSTAMP - clear the timestamp for messages (the *stamp* parameter in `getMsgs.json` request), STATE_STREAMS - update the list of streams (see also `getStreams.json`), STATE_CONFIG - get the current client config (see also `getConfig.json`), Resetting STATE_DEVICES, STATE_RECORDS, STATE_MSGS, STATE_STREAMS, STATE_CONFIG states will update the selected state from the client's thread. During the execution of main loop, requests `getDevicesOnline.json`, `getRecordCount.json`, `getMsgs.json`, `getStreams.json` and `getConfig.json` will be generated and launched, respectively. `aStateId` is the selected client state, The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOn... methods). The `callback` can be passed as: 1. a pair of values - a callback (JSONArrayNotifyEventFunc) and user data (any) 2. just a reference to a callback of type JSONArrayNotifyEventFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) IsClientStatusInRange ¶
func (c *WCClient) IsClientStatusInRange(st []ClientStatus) bool
Check is the client status in the given range
func (*WCClient) LaunchInStream ¶
func (c *WCClient) LaunchInStream(aDeviceName string, onNewFrame TaskNotifyFunc, userdata ...any) error
Launch incoming stream for authorized client (sa `output.raw` request).
`aDeviceName` is the name of streaming device to listen, `onNewFrame` is the callback to catch the `new frame` event, `userdata` is the additional user data that passed to the new task (GetUserData) `return` nil on success or the error object.
func (*WCClient) LaunchOutStream ¶
Launch output stream for authorized client (sa `input.raw` request).
`subProtocol` is the sub protocol description, `delta` is the delta time between frames in ms, `userdata` is the additional user data that passed to the new task (GetUserData) `return` nil on success or the error object.
func (*WCClient) PopInFrame ¶
Get the new frame from the incoming stream (sa `output.raw` request).
`return` bytes.Buffer with the frame body on success or the error object. If there is no frames in the stream sequece - the function returns both nil for Buffer and error results
func (*WCClient) PushOutData ¶
Push the new data frame to the output stream (sa `input.raw` request).
`data` is the byte buffer with the frame header and its body `return` nil on success or the error object.
func (*WCClient) RequestRecord ¶
Get the blob data of the media record (see also `getRecordData.json`).
`rid` is the id of the media record `userdata` is the additional user data that passed to the new task (GetUserData) `return` nil on success or the error object.
func (*WCClient) RequestRecordMeta ¶
Get the metadata for the media record (see also `getRecordMeta.json`).
`rid` is the id of the media record The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnReqRecordMeta method). The `callback` can be passed as: 1. a pair of values - a callback (JSONNotifyEventFunc) and user data (any) 2. just a reference to a callback of type JSONNotifyEventFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) SaveRecord ¶
func (c *WCClient) SaveRecord(aBuf io.ReadCloser, aBufSize int64, meta string, callback ...any) error
Save the media record (see also `addRecord.json`).
`aBuf` is the user-specified Reader with the frame data `aBufSize` is the frame size, mandatory if the Reader is not provided content length by itself `meta` is additional metadata for the saving media record The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnSuccessSaveRecord method). The `callback` can be passed as: 1. a pair of values - a callback (TaskNotifyFunc) and user data (any) 2. just a reference to a callback of type TaskNotifyFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) SendMsgs ¶
Send a new message(s) to the server from device.
See protocol request `addMsgs.json`. `aMsg` is the message object or array of messages. Allowable type for `aMsg` is: 1. map[string]any 2. *OutMessageStruct - to send one outgoing message 3. []map[string]any 4. []*OutMessageStruct - to send several outgoing messages The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnSuccessSendMsg method). The `callback` can be passed as: 1. a pair of values - a callback (TaskNotifyFunc) and user data (any) 2. just a reference to a callback of type TaskNotifyFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) SetConfig ¶
Send configuration of authorized client to the server (sa `setConfig.json` request).
`aStr` is the array of configuration elements. The possible types of each element in this array are: map[string]any or *OutConfigElementStruct The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnSetConfig method). The `callback` can be passed as: 1. a pair of values - a callback (TaskNotifyFunc) and user data (any) 2. just a reference to a callback of type TaskNotifyFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) SetLstMsgStamp ¶
Set the timestamp of the last received message
func (*WCClient) SetLstMsgStampToSyncPoint ¶
func (c *WCClient) SetLstMsgStampToSyncPoint()
Reset the timestamp of the last received message to the sync point
func (*WCClient) SetLstRecStamp ¶
Set the timestamp of the last received media record
func (*WCClient) SetNeedToSync ¶
Set is the next update of the message list will occur with or without the sending of a 'sync' message (sa. getMsgsAndSync - WCPD)
func (*WCClient) SetOnAddLog ¶
func (c *WCClient) SetOnAddLog(event StringNotifyFunc)
Set new callback for the "Added new log entry" event.
`event` is the reference to the callback function
func (*WCClient) SetOnAfterLaunchInStream ¶
func (c *WCClient) SetOnAfterLaunchInStream(event TaskNotifyFunc)
Set new callback for the "Incoming stream started" event.
`event` is the reference to the callback function
func (*WCClient) SetOnAfterLaunchOutStream ¶
func (c *WCClient) SetOnAfterLaunchOutStream(event TaskNotifyFunc)
Set new callback for the "Outgoing stream started" event.
`event` is the reference to the callback function
func (*WCClient) SetOnAuthSuccess ¶
func (c *WCClient) SetOnAuthSuccess(event TaskNotifyFunc)
Set new callback for the "Successful authorization" event.
`event` is the reference to the callback function
func (*WCClient) SetOnConnected ¶
func (c *WCClient) SetOnConnected(event ConnNotifyEventFunc)
Set new callback for the "The connection state has been changed" event.
`event` is the reference to the callback function
func (*WCClient) SetOnDisconnect ¶
func (c *WCClient) SetOnDisconnect(event NotifyEventFunc)
Set new callback for the "Client has been disconnected" event.
`event` is the reference to the callback function
func (*WCClient) SetOnGetConfig ¶
func (c *WCClient) SetOnGetConfig(event JSONArrayNotifyEventFunc)
Set new callback for the "The request to get actual config has been completed. The response has arrived" event.
`event` is the reference to the callback function `jsonresult` inside JSONArrayNotifyEventFunc will contain reference to the array of the incoming config elements
func (*WCClient) SetOnReqRecordData ¶
func (c *WCClient) SetOnReqRecordData(event DataNotifyEventFunc)
Set new callback for the "The request to get the media record has been completed. The response has arrived" event.
`event` is the reference to the callback function `data` inside DataNotifyEventFunc will contain reference to the byte buffer
func (*WCClient) SetOnReqRecordMeta ¶
func (c *WCClient) SetOnReqRecordMeta(event JSONNotifyEventFunc)
Set new callback for the "The request to get metadata for the media record has been completed. The response has arrived" event.
`event` is the reference to the callback function `jsonresult` inside JSONNotifyEventFunc will contain reference to the meta data for the media record
func (*WCClient) SetOnSetConfig ¶
func (c *WCClient) SetOnSetConfig(event TaskNotifyFunc)
Set new callback for the "The request to set a new config has been completed. The response has arrived" event.
`event` is the reference to the callback function
func (*WCClient) SetOnSuccessDeleteRecords ¶
func (c *WCClient) SetOnSuccessDeleteRecords(event TaskNotifyFunc)
Set new callback for the "The request to delete records has been completed. The response has arrived" event.
`event` is the reference to the callback function
func (*WCClient) SetOnSuccessIOStream ¶
func (c *WCClient) SetOnSuccessIOStream(event TaskNotifyFunc)
Set new callback for the "IO stream terminated for some reason" event.
`event` is the reference to the callback function
func (*WCClient) SetOnSuccessSaveRecord ¶
func (c *WCClient) SetOnSuccessSaveRecord(event TaskNotifyFunc)
Set new callback for the "The request to save the media record has been completed. The response has arrived" event.
`event` is the reference to the callback function
func (*WCClient) SetOnSuccessSendMsg ¶
func (c *WCClient) SetOnSuccessSendMsg(event TaskNotifyFunc)
Set new callback for the "The request to get metadata for the media record has been completed. The response has arrived" event.
`event` is the reference to the callback function
func (*WCClient) SetOnUpdateDevices ¶
func (c *WCClient) SetOnUpdateDevices(event JSONArrayNotifyEventFunc)
Set new callback for the "The request to update list of online devices has been completed. The response has arrived" event.
`event` is the reference to the callback function `jsonresult` inside JSONArrayNotifyEventFunc will contain reference to the array of the online devices
func (*WCClient) SetOnUpdateMsgs ¶
func (c *WCClient) SetOnUpdateMsgs(event JSONArrayNotifyEventFunc)
Set new callback for the "The request to update list of messages has been completed. The response has arrived" event.
`event` is the reference to the callback function `jsonresult` inside JSONArrayNotifyEventFunc will contain reference to the array of the incoming messages
func (*WCClient) SetOnUpdateRecords ¶
func (c *WCClient) SetOnUpdateRecords(event JSONArrayNotifyEventFunc)
Set new callback for the "The request to update list of media records has been completed. The response has arrived" event.
`event` is the reference to the callback function `jsonresult` inside JSONArrayNotifyEventFunc will contain reference to the array of the media records (with no data. to get the data of media record by its id use the GetRecordData/GetRecordMeta methods)
func (*WCClient) SetOnUpdateStreams ¶
func (c *WCClient) SetOnUpdateStreams(event JSONArrayNotifyEventFunc)
Set new callback for the "The request to update list of streaming devices has been completed The response has arrived" event.
`event` is the reference to the callback function `jsonresult` inside JSONArrayNotifyEventFunc will contain reference to the array of the streaming devices
func (*WCClient) SetSIDSetted ¶
func (c *WCClient) SetSIDSetted(event StringNotifyFunc)
Set new callback for the "The session id has been changed" event.
`event` is the reference to the callback function
func (*WCClient) Start ¶
Launch client.
The function initializes and starts the client''s working thread. After calling this method the assigned client configuration will be locked `return` nil on success or error object.
func (*WCClient) UpdateDevices ¶
Update the list of devices (see also `getDevicesOnline.json`).
The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnUpdateDevices method). The `callback` can be passed as: 1. a pair of values - a callback (JSONArrayNotifyEventFunc) and user data (any) 2. just a reference to a callback of type JSONArrayNotifyEventFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) UpdateMsgs ¶
Get new messages from the server.
See protocol requests ` getMsgs.json`, `getMsgsAndSync.json`. According to the results of the request, the STATE_MSGSSTAMP state will be updated automatically. The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnUpdateMsgs method). The `callback` can be passed as: 1. a pair of values - a callback (JSONArrayNotifyEventFunc) and user data (any) 2. just a reference to a callback of type JSONArrayNotifyEventFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) UpdateRecords ¶
Update the list of media records (see also `getRecordCount.json`).
According to the results of the request, the STATE_RECORDSSTAMP state will be updated automatically. The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnUpdateRecords method). The `callback` can be passed as: 1. a pair of values - a callback (JSONArrayNotifyEventFunc) and user data (any) 2. just a reference to a callback of type JSONArrayNotifyEventFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
func (*WCClient) UpdateStreams ¶
Update the list of streams (see also `getStreams.json`).
The `callback` is the callback data that is used upon successful completion. if a null or empty value is set, the client calls a predefined corresponding function (\sa WCClient.SetOnUpdateStreams method). The `callback` can be passed as: 1. a pair of values - a callback (JSONArrayNotifyEventFunc) and user data (any) 2. just a reference to a callback of type JSONArrayNotifyEventFunc 3. user data (any) - \sa ITask.GetUserData `return` nil on success or the error object.
type WCClientConfig ¶
type WCClientConfig struct {
// contains filtered or unexported fields
}
func (*WCClientConfig) AssignFrom ¶
func (c *WCClientConfig) AssignFrom(src *WCClientConfig) error
Clone config from other instance
func (*WCClientConfig) GetDevice ¶
func (c *WCClientConfig) GetDevice() string
Get the assigned device name
func (*WCClientConfig) GetHost ¶
func (c *WCClientConfig) GetHost() string
Get the assigned server host address
func (*WCClientConfig) GetMeta ¶
func (c *WCClientConfig) GetMeta() string
Get the assigned meta data for the device (sa. "authorize.json" - WCPD)
func (*WCClientConfig) GetPort ¶
func (c *WCClientConfig) GetPort() int
Get the assigned server host port
func (*WCClientConfig) GetUrl ¶
func (c *WCClientConfig) GetUrl(command string) string
Get the complete url for the JSON-request
func (*WCClientConfig) GetVerifyTLS ¶
func (c *WCClientConfig) GetVerifyTLS() bool
Get the value of the flag - should client verify TLS certificate
func (*WCClientConfig) SetDevice ¶
func (c *WCClientConfig) SetDevice(device string) error
Set the device name
func (*WCClientConfig) SetHostURL ¶
func (c *WCClientConfig) SetHostURL(hosturl string) error
Set the server host address `https://[username[:password]@]hostname[:port]`
func (*WCClientConfig) SetMeta ¶
func (c *WCClientConfig) SetMeta(val string) error
Set new meta data for the device (sa. "authorize.json" - WCPD)
func (*WCClientConfig) SetPort ¶
func (c *WCClientConfig) SetPort(port int) error
Set the server host port
func (*WCClientConfig) SetProxy ¶
func (c *WCClientConfig) SetProxy(proxy string) error
Set the server proxy params in format `[scheme:]//[user[:password]@]host[:port]`
func (*WCClientConfig) SetVerifyTLS ¶
func (c *WCClientConfig) SetVerifyTLS(sec bool) error
Set or unset the flag - should client verify TLS certificate