eventsocket

package module
v0.0.0-...-5a5b051 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2013 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize = 16 * 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Settings   ClientSettings
	Connected  bool
	Connection Connection
}

func CreateClient

func CreateClient(settings ClientSettings) (*Client, error)

func (*Client) Loop

func (client *Client) Loop()

type ClientSettings

type ClientSettings struct {
	Address  string
	Timeout  time.Duration
	Password string
	Listener ConnectionListener
}

type Command

type Command struct {
	Lock bool
	Uuid string
	App  string
	Args string
}

func (*Command) GetExecute

func (cmd *Command) GetExecute() []byte

GetExecute formats a dialplan command to be sent over TCP Connection

type Connection

type Connection struct {
	//server specific
	Server *Server

	//client specific
	Reconnects  int
	ChannelData ESLkv
	Connected   bool

	//generic
	Listener ConnectionListener
	// contains filtered or unexported fields
}

func (*Connection) Close

func (con *Connection) Close()

func (*Connection) Event

func (con *Connection) Event(cmd string, headers map[string]string, body []byte) (*Event, error)

func (*Connection) Execute

func (con *Connection) Execute(cmd *Command) (*Event, error)

func (*Connection) Loop

func (con *Connection) Loop()

func (*Connection) Send

func (con *Connection) Send(cmd string, args ...string) (*Event, error)

type ConnectionListener

type ConnectionListener interface {
	OnConnect(con *Connection)
	OnEvent(con *Connection, evt *Event)
	OnDisconnect(con *Connection, msg *Event)
	OnClose(con *Connection)
}

type ESLkv

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

func (*ESLkv) Get

func (eB *ESLkv) Get(key string) string

type Event

type Event struct {
	Type      EventType
	Headers   ESLkv
	Body      []byte
	EventBody ESLkv
	Success   bool
}

type EventType

type EventType int

EventType indicates how/why this event is being raised

const (
	//Parser and Socket errors
	EventError EventType = iota
	//Client Mode: Connection established / terminated
	//Server Mode: New Connection / Lost Connection
	EventState
	//Library internal, used during auth phase
	EventAuth
	//Command Reply
	EventReply
	//API (reloadxml,reloadacl) commands
	EventApi
	//Received a disconnect notice (linger might still be on)
	EventDisconnect
	//Subscribed events
	EventGeneric
)

type Server

type Server struct {
	Settings    ServerSettings
	NetListener net.Listener
	EvListener  ServerListener
}

func CreateServer

func CreateServer(settings ServerSettings) (*Server, error)

func (*Server) Loop

func (server *Server) Loop()

type ServerListener

type ServerListener interface {
	OnNewConnection(con *Connection)
}

type ServerSettings

type ServerSettings struct {
	Address  string
	Listener ServerListener
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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