codec

package
v0.0.0-...-b44964e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0 Imports: 36 Imported by: 2

Documentation

Overview

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2014-2019 Cesanta Software Limited All rights reserved

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	AzureDMURLScheme = "azdm"
)
View Source
const (
	// gcp://project/region/registry/device?topic=...&sub=...&reqsf=....&respsf=...
	GCPURLScheme = "gcp"
)
View Source
const (
	UDPURLScheme = "udp"
)
View Source
const (
	WSProtocol = "clubby.cesanta.com"
)
View Source
const (
	WatsonURLScheme = "watson"
)

Variables

This section is empty.

Functions

func IsEOF

func IsEOF(err error) bool

IsEOF returns true when err means "end of file".

func MQTTClientOptsFromURL

func MQTTClientOptsFromURL(us, clientID, user, pass string) (*mqtt.ClientOptions, string, error)

func MkDigestResp

func MkDigestResp(method, uri, username, realm, passwd, algorithm, nonce, nc, qop string) (int, string, error)

Types

type AzureDMCodecOptions

type AzureDMCodecOptions struct {
	ConnectionString string
}

type Codec

type Codec interface {
	// Recv returns the next incoming frame.
	Recv(context.Context) (*frame.Frame, error)
	// Send sends the frame to the remote peer.
	Send(context.Context, *frame.Frame) error
	// Close closes the channel.
	Close()
	// CloseNotify() returns a channel that will be closed once the underlying channel has been closed.
	CloseNotify() <-chan struct{}
	// Can accept this many outgoing frames. 0 means no frames can be sent, values < 0 mean no limit.
	MaxNumFrames() int
	// Info() returns information about underlying connection.
	Info() ConnectionInfo
	// SetOptions() adjusts codec options.
	SetOptions(opts *Options) error
}

Codec represents a transport for clubby frames.

func InboundHTTP

func InboundHTTP(rw http.ResponseWriter, req *http.Request, cloudHost string) Codec

func MQTT

func MQTT(dst string, tlsConfig *tls.Config, co *MQTTCodecOptions) (Codec, error)

func NewAzureDMCodec

func NewAzureDMCodec(connectURL string, opts *AzureDMCodecOptions) (Codec, error)

func NewGCPCodec

func NewGCPCodec(connectURL string, opts *GCPCodecOptions) (Codec, error)

func NewReconnectWrapperCodec

func NewReconnectWrapperCodec(addr string, connect ConnectFunc) Codec

func NewWatsonCodec

func NewWatsonCodec(dst string, tlsConfig *tls.Config, co *WatsonCodecOptions) (Codec, error)

func OutboundHTTP

func OutboundHTTP(url string, tlsConfig *tls.Config, opts OutboundHTTPCodecOptions) Codec

OutboundHTTP sends outbound frames in HTTP POST requests and returns replies with Recv.

func Serial

func Serial(ctx context.Context, portName string, opts *SerialCodecOptions) (Codec, error)

func TCP

func TCP(conn net.Conn) Codec

func UDP

func UDP(addr string) Codec

func WebSocket

func WebSocket(conn *websocket.Conn) Codec

type ConnectFunc

type ConnectFunc func(addr string) (Codec, error)

type ConnectionInfo

type ConnectionInfo struct {
	IsConnected bool
	// TLS indicates if the connection uses TLS or not.
	TLS bool
	// RemoteAddr is the address of the remote peer.
	RemoteAddr string
	// PeerCertificates is the certificate chain presented by the peer.
	PeerCertificates []*x509.Certificate
}

ConnectionInfo provides information about the connection.

type GCPCodecOptions

type GCPCodecOptions struct {
	CreateTopic bool
}

type MQTTCodecOptions

type MQTTCodecOptions struct {
	// Note: user:password in the connect URL, if set, will take precedence over these.
	User     string
	Password string
	ClientID string
	PubTopic string
	SubTopic string
	Src      string
}

type OutboundHTTPCodecOptions

type OutboundHTTPCodecOptions struct {
	GetCredsCallback func() (username, passwd string, err error)
}

type SerialCodecOptions

type SerialCodecOptions struct {
	BaudRate             uint
	HardwareFlowControl  bool
	SendChunkSize        int
	SendChunkDelay       time.Duration
	JunkHandler          func(junk []byte)
	SetControlLines      bool
	InvertedControlLines bool
}

type UDPCodecOptions

type UDPCodecOptions struct {
}

type WatsonCodecOptions

type WatsonCodecOptions struct {
	AppID        string // a random one will be generated if not set
	APIKey       string
	APIAuthToken string
}

Jump to

Keyboard shortcuts

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