transaction

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Originally forked from https://github.com/ghettovoice/gosip by @ghetovoice

transaction package implements SIP Transaction Layer

Index

Constants

View Source
const (
	T1        = 500 * time.Millisecond
	T2        = 4 * time.Second
	T4        = 5 * time.Second
	Timer_A   = T1
	Timer_B   = 64 * T1
	Timer_D   = 32 * time.Second
	Timer_E   = T1
	Timer_F   = 64 * T1
	Timer_G   = T1
	Timer_H   = 64 * T1
	Timer_I   = T4
	Timer_J   = 64 * T1
	Timer_K   = T4
	Timer_1xx = 200 * time.Millisecond
	Timer_L   = 64 * T1
	Timer_M   = 64 * T1

	TxSeperator = "__"
)

Variables

View Source
var (
	// Transaction Layer Errors can be detected and handled with different response on caller side
	// https://www.rfc-editor.org/rfc/rfc3261#section-8.1.3.1
	ErrTimeout   = errors.New("transaction timeout")
	ErrTransport = errors.New("transaction transport error")
)

Functions

func MakeClientTxKey

func MakeClientTxKey(msg sip.Message) (string, error)

MakeClientTxKey creates client key for matching responses - RFC 3261 17.1.3.

func MakeServerTxKey

func MakeServerTxKey(msg sip.Message) (string, error)

MakeServerTxKey creates server key for matching retransmitting requests - RFC 3261 17.2.3.

Types

type ClientTx

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

func NewClientTx

func NewClientTx(key string, origin *sip.Request, conn transport.Connection, logger zerolog.Logger) *ClientTx

func (*ClientTx) Cancel

func (tx *ClientTx) Cancel() error

Cancel cancels client transaction by sending CANCEL request

func (*ClientTx) Done

func (tx *ClientTx) Done() <-chan struct{}

func (*ClientTx) Err added in v0.8.0

func (tx *ClientTx) Err() error

func (*ClientTx) Init

func (tx *ClientTx) Init() error

func (*ClientTx) Key

func (tx *ClientTx) Key() string

func (*ClientTx) OnTerminate

func (tx *ClientTx) OnTerminate(f FnTxTerminate)

func (*ClientTx) Origin

func (tx *ClientTx) Origin() *sip.Request

func (*ClientTx) Receive

func (tx *ClientTx) Receive(res *sip.Response) error

func (*ClientTx) Responses

func (tx *ClientTx) Responses() <-chan *sip.Response

func (*ClientTx) String

func (tx *ClientTx) String() string

func (*ClientTx) Terminate

func (tx *ClientTx) Terminate()

type ErrorHandler

type ErrorHandler func(err error)

type FSMfunc

type FSMfunc func() FSMfunc

type FnTxTerminate

type FnTxTerminate func(key string)

type FsmContextState

type FsmContextState func(s FsmInput) FsmInput

type FsmInput

type FsmInput int
const (
	FsmInputNone FsmInput = iota
)

FSM Inputs

type FsmState

type FsmState func() FsmInput

type Layer

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

func NewLayer

func NewLayer(tpl *transport.Layer) *Layer

func (*Layer) Close

func (txl *Layer) Close()

func (*Layer) OnRequest

func (txl *Layer) OnRequest(h RequestHandler)

func (*Layer) Request

func (txl *Layer) Request(req *sip.Request) (*ClientTx, error)

func (*Layer) Respond

func (txl *Layer) Respond(res *sip.Response) (*ServerTx, error)

func (*Layer) Transport

func (txl *Layer) Transport() sip.Transport

func (*Layer) UnhandledResponseHandler

func (txl *Layer) UnhandledResponseHandler(f UnhandledResponseHandler)

UnhandledResponseHandler can be used in case missing client transactions for handling response ServerTransaction handle responses by state machine

type RequestHandler

type RequestHandler func(req *sip.Request, tx sip.ServerTransaction)

type ServerTx

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

func NewServerTx

func NewServerTx(key string, origin *sip.Request, conn transport.Connection, logger zerolog.Logger) *ServerTx

func (*ServerTx) Acks

func (tx *ServerTx) Acks() <-chan *sip.Request

Acks makes channel for sending acks. Channel is created on demand

func (*ServerTx) Cancels

func (tx *ServerTx) Cancels() <-chan *sip.Request

func (*ServerTx) Done

func (tx *ServerTx) Done() <-chan struct{}

func (*ServerTx) Err added in v0.8.0

func (tx *ServerTx) Err() error

func (*ServerTx) Init

func (tx *ServerTx) Init() error

func (*ServerTx) Key

func (tx *ServerTx) Key() string

func (*ServerTx) OnTerminate

func (tx *ServerTx) OnTerminate(f FnTxTerminate)

func (*ServerTx) Origin

func (tx *ServerTx) Origin() *sip.Request

func (*ServerTx) Receive

func (tx *ServerTx) Receive(req *sip.Request) error

Receive is endpoint for handling received server requests.

func (*ServerTx) Respond

func (tx *ServerTx) Respond(res *sip.Response) error

func (*ServerTx) String

func (tx *ServerTx) String() string

func (*ServerTx) Terminate

func (tx *ServerTx) Terminate()

type UnhandledResponseHandler

type UnhandledResponseHandler func(req *sip.Response)

Jump to

Keyboard shortcuts

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