apc

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 17 Imported by: 0

README

go-apc

GoDoc Widget Go Report

The library to work with Avaya Proactive Control Agent API. It replaces the old ActiveX component. Supports old versions with TLS 1.0 only support. Due to incompatibility with BEAST patched clients Go tls package was forked.

cmd/apcctl contains source code of the example utility that logins, attaches a job and receives events. Additional documentation.

It lacks tests, but was battle-tested under real production loads without major changes.

Documentation

Index

Constants

View Source
const (
	// ConnOK means that connection is currently online
	ConnOK uint32 = iota
	// ConnClosed means that connection is currently closing or already closed
	ConnClosed
)
View Source
const (
	// RS is Message separator
	RS byte = 0x1E
	// ETB is IsIncomplete message separator
	ETB byte = 0x17
	// ETX is End of text
	ETX byte = 0x03
)

Variables

View Source
var (
	ErrConnectionClosed = errors.New("connection closed")
	ErrHelloNotReceived = errors.New("hello not received")
)

Functions

func IsDecodingError

func IsDecodingError(err error) bool

func LogLevelToString

func LogLevelToString(l LogLevel) string

LogLevelToString transforms Level to its string representation.

Types

type AvayaError

type AvayaError struct {
	Code string
}

func (AvayaError) Error

func (e AvayaError) Error() string

type Client

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

func NewClient

func NewClient(addr string, opts ...Option) (*Client, error)

NewClient returns Avaya Proactive Client Agent API client to work with. Client keeps alive underlying connection, because APC proto is stateful.

func (*Client) AttachJob

func (c *Client) AttachJob(ctx context.Context, jobName string) error

func (*Client) AvailWork

func (c *Client) AvailWork(ctx context.Context) error

func (*Client) ConnectHeadset

func (c *Client) ConnectHeadset(ctx context.Context) error

func (*Client) DetachJob

func (c *Client) DetachJob(ctx context.Context) error

func (*Client) DisconnectHeadset

func (c *Client) DisconnectHeadset(ctx context.Context) error

func (*Client) EchoOff

func (c *Client) EchoOff(ctx context.Context) error

func (*Client) EchoOn

func (c *Client) EchoOn(ctx context.Context) error

func (*Client) FinishedItem

func (c *Client) FinishedItem(ctx context.Context, compCode int) error

func (*Client) FreeHeadset

func (c *Client) FreeHeadset(ctx context.Context) error

func (*Client) ListCallFields

func (c *Client) ListCallFields(ctx context.Context, listName string) ([]string, error)

func (*Client) ListCallLists

func (c *Client) ListCallLists(ctx context.Context) ([]string, error)

func (*Client) ListDataFields

func (c *Client) ListDataFields(ctx context.Context, listType ListType) ([]DataField, error)

func (*Client) ListJobs

func (c *Client) ListJobs(ctx context.Context, jobType JobType) ([]Job, error)

func (*Client) ListKeys

func (c *Client) ListKeys(ctx context.Context) ([]string, error)

func (*Client) ListState

func (c *Client) ListState(ctx context.Context) (*State, error)

func (*Client) LogIoStart

func (c *Client) LogIoStart(ctx context.Context) error

func (*Client) LogIoStop

func (c *Client) LogIoStop(ctx context.Context) error

func (*Client) Logoff

func (c *Client) Logoff(ctx context.Context) error

Logoff sends ATGLogoff command, then Proactive Control server terminates session

func (*Client) Logon

func (c *Client) Logon(ctx context.Context, agentName string, password string) error

func (*Client) NoFurtherWork

func (c *Client) NoFurtherWork(ctx context.Context) error

func (*Client) Notifications

func (c *Client) Notifications(ctx context.Context) <-chan Notification

Notifications returns read-only notification event channel.

func (*Client) ReadField

func (c *Client) ReadField(ctx context.Context, listType ListType, fieldName string) (*Field, error)

func (*Client) ReadyNextItem

func (c *Client) ReadyNextItem(ctx context.Context) error

func (*Client) ReleaseLine

func (c *Client) ReleaseLine(ctx context.Context) error

func (*Client) ReserveHeadset

func (c *Client) ReserveHeadset(ctx context.Context, headsetID int) error

func (*Client) SetDataField

func (c *Client) SetDataField(ctx context.Context, listType ListType, fieldName string) error

func (*Client) SetNotifyKeyField

func (c *Client) SetNotifyKeyField(ctx context.Context, listType ListType, fieldName string) error

func (*Client) Start

func (c *Client) Start() error

Start starts main event loop handler.

type DataField

type DataField struct {
	Name string
}

type Event

type Event struct {
	Keyword      string
	Type         EventType
	Client       string
	ProcessID    uint32
	InvokeID     uint32
	Segments     []string
	IsIncomplete bool
}

func (Event) IsDataMessage

func (e Event) IsDataMessage() bool

func (Event) IsNotificationData

func (e Event) IsNotificationData() bool

func (Event) IsNotificationError

func (e Event) IsNotificationError() bool

func (Event) IsPending

func (e Event) IsPending() bool

func (Event) IsResponseError

func (e Event) IsResponseError() bool

func (Event) IsStart

func (e Event) IsStart() bool

func (Event) IsSuccessfulNotification

func (e Event) IsSuccessfulNotification() bool

func (Event) IsSuccessfulResponse

func (e Event) IsSuccessfulResponse() bool

type EventType

type EventType byte
const (
	EventTypeCommand      EventType = 'C'
	EventTypePending      EventType = 'P'
	EventTypeData         EventType = 'D'
	EventTypeResponse     EventType = 'R'
	EventTypeBusy         EventType = 'B'
	EventTypeNotification EventType = 'N'
)

type Field

type Field struct {
	Name   string
	Type   FieldType
	Length int
	Value  string
}

type FieldType

type FieldType string
const (
	FieldTypeAlphanumeric FieldType = "A"
	FieldTypeNumeric      FieldType = "N"
	FieldTypeDate         FieldType = "D"
	FieldTypeCurrency     FieldType = "$"
	FieldTypeFutureUse    FieldType = "F"
)

type Job

type Job struct {
	Type   JobType
	Name   string
	Status StatusType
}

type JobType

type JobType byte
const (
	JobTypeAll      JobType = 'A'
	JobTypeBlend    JobType = 'B'
	JobTypeOutbound JobType = 'O'
	JobTypeInbound  JobType = 'I'
	JobTypeManaged  JobType = 'M'
)

type ListType

type ListType byte
const (
	ListTypeOutbound ListType = 'O'
	ListTypeInbound  ListType = 'I'
)

type LogEntry

type LogEntry struct {
	Level   LogLevel
	Message string
	Fields  map[string]interface{}
}

LogEntry represents log entry.

type LogHandler

type LogHandler func(LogEntry)

LogHandler handles log entries - i.e. writes into correct destination if necessary.

type LogLevel

type LogLevel int

LogLevel describes the chosen log level.

const (
	// LogLevelNone means no logging.
	LogLevelNone LogLevel = iota
	// LogLevelDebug turns on debug logs - its generally too much for production in normal
	// conditions but can help when developing and investigating problems in production.
	LogLevelDebug
	// LogLevelInfo is logs useful server information. This includes various information
	// about problems with client connections which is not Centrifugo errors but
	// in most situations malformed client behaviour.
	LogLevelInfo
	// LogLevelError level logs only server errors. This is logging that means non-working
	// Centrifugo and maybe effort from developers/administrators to make things
	// work again.
	LogLevelError
)

type Notification

type Notification struct {
	Type    NotificationType
	Payload interface{}
}

type NotificationType

type NotificationType string
const (
	NotificationTypeCallNotify        NotificationType = "AGTCallNotify"
	NotificationTypeAutoReleaseLine   NotificationType = "AGTAutoReleaseLine"
	NotificationTypeJobEnd            NotificationType = "AGTJobEnd"
	NotificationTypeReceiveMessage    NotificationType = "AGTReceiveMessage"
	NotificationTypeJobTransRequest   NotificationType = "AGTJobTransRequest"
	NotificationTypeHeadsetConnBroken NotificationType = "AGTHeadsetConnBroken"
	NotificationTypeSystemError       NotificationType = "AGTSystemError"
)

type Option

type Option func(*Options)

func WithDecoder

func WithDecoder(decoder *encoding.Decoder) Option

WithDecoder returns an Option with custom decoder e.g w/ charmap.Windows1251.NewDecoder().

func WithLogHandler

func WithLogHandler(logLevel LogLevel, handler LogHandler) Option

WithLogHandler returns an Option with custom log handler.

func WithLogger

func WithLogger() Option

WithLogger returns an Option with zap logger (JSON).

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout returns an Option with Timeout for underlying Client connection.

func WithTlsPatched

func WithTlsPatched() Option

WithTlsPatched returns an Option with patched TLS package to fix issues with old TLS 1.0 only Avaya server

func WithTlsSkipVerify

func WithTlsSkipVerify() Option

WithTlsSkipVerify returns an Option with flag to skip TLS verification (insecure!)

type Options

type Options struct {
	Timeout       *time.Duration
	LogLevel      LogLevel
	LogHandler    LogHandler
	Decoder       *encoding.Decoder
	TlsPatched    bool
	TlsSkipVerify bool
}

type State

type State struct {
	Type    StateType
	JobName string
}

type StateType

type StateType string
const (
	StateTypeOnCall         StateType = "S70000"
	StateTypeReadyForCall   StateType = "S70001"
	StateTypeHasJoinedJob   StateType = "S70002"
	StateTypeHasSelectedJob StateType = "S70003"
	StateTypeLoggedOn       StateType = "S70004"
)

type StatusType

type StatusType byte
const (
	StatusTypeInactive StatusType = 'I'
	StatusTypeActive   StatusType = 'A'
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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