ws

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNormalCloseError

func IsNormalCloseError(err error) bool

func IsWebSocketUpgrade

func IsWebSocketUpgrade(r *http.Request) bool

Types

type Action

type Action string

type CallErrorMessage

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

func NewCallErrorMessage

func NewCallErrorMessage(id MessageID, errorCode ErrorCode, errorDescription string) *CallErrorMessage

func (*CallErrorMessage) Error

func (err *CallErrorMessage) Error() string

func (*CallErrorMessage) ID

func (err *CallErrorMessage) ID() MessageID

func (*CallErrorMessage) MarshalJSON

func (err *CallErrorMessage) MarshalJSON() ([]byte, error)

func (*CallErrorMessage) Type

func (err *CallErrorMessage) Type() MessageType

type CallMessage

type CallMessage struct {
	Action
	Payload map[string]interface{}
	// contains filtered or unexported fields
}

func NewCallMessage

func NewCallMessage(id MessageID, action Action, payload map[string]interface{}) *CallMessage

func UnmarshalRequest

func UnmarshalRequest(id MessageID, req messages.Request) (*CallMessage, error)

func (*CallMessage) ID

func (call *CallMessage) ID() MessageID

func (*CallMessage) MarshalJSON

func (call *CallMessage) MarshalJSON() ([]byte, error)

func (*CallMessage) Type

func (call *CallMessage) Type() MessageType

type CallResponse

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

type CallResultMessage

type CallResultMessage struct {
	Payload interface{} //map[string]interface{}
	// contains filtered or unexported fields
}

func NewCallResult

func NewCallResult(id MessageID, payload interface{}) *CallResultMessage

func (*CallResultMessage) ID

func (result *CallResultMessage) ID() MessageID

func (*CallResultMessage) MarshalJSON

func (result *CallResultMessage) MarshalJSON() ([]byte, error)

func (*CallResultMessage) Type

func (result *CallResultMessage) Type() MessageType

type Conn

type Conn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

func Dial

func Dial(identity, csURL string, version ocpp.Version) (*Conn, error)

func Handshake

func Handshake(w http.ResponseWriter, r *http.Request, supportedVersions []ocpp.Version) (*Conn, error)

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() error

func (*Conn) Requests

func (c *Conn) Requests() <-chan struct {
	messages.Request
	MessageID
}

func (*Conn) SendRequest

func (c *Conn) SendRequest(request messages.Request) (messages.Response, error)

func (*Conn) SendResponse

func (c *Conn) SendResponse(id MessageID, response messages.Response, err error) error

func (*Conn) WriteJSON

func (c *Conn) WriteJSON(data interface{}) error

type ErrorCode

type ErrorCode string
const (
	// NotSupported when Requested Action is recognized but not supported by the receiver
	NotSupported ErrorCode = "NotSupported"
	// InternalError when An internal error occurred and the receiver was not able to process the requested Action successfully
	InternalError ErrorCode = "InternalError"
	// ProtocolError when Payload for Action is incomplete
	ProtocolError ErrorCode = "ProtocolError"
	// SecurityError when During the processing of Action a security issue occurred preventing receiver from completing the Action successfully
	SecurityError ErrorCode = "SecurityError"
	// FormationViolation when Payload for Action is syntactically incorrect or not conform the PDU structure for Action
	FormationViolation ErrorCode = "FormationViolation"
	// PropertyConstraintViolation when Payload is syntactically correct but at least one field contains an invalid value
	PropertyConstraintViolation ErrorCode = "PropertyConstraintViolation"
	// OccurenceConstraintViolation when Payload for Action is syntactically correct but at least one of the fields violates occurence constraints
	OccurenceConstraintViolation ErrorCode = "OccurenceConstraintViolation"
	// TypeConstraintViolation when Payload for Action is syntactically correct but at least one of the fields violates data type constraints (e.g. “somestring”: 12)
	TypeConstraintViolation ErrorCode = "TypeConstraintViolation"
	// GenericError when Any other error not covered by the previous ones
	GenericError ErrorCode = "GenericError"
	// Nil no error
	Nil ErrorCode = ""
)

func (ErrorCode) Error

func (code ErrorCode) Error() string

type Message

type Message interface {
	Type() MessageType
	ID() MessageID
}

func UnmarshalMessage

func UnmarshalMessage(msg []byte) (Message, error)

type MessageID

type MessageID string

type MessageType

type MessageType float64
const (
	Call       MessageType = 2
	CallResult MessageType = 3
	CallError  MessageType = 4
)

Jump to

Keyboard shortcuts

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