siptx

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package siptx runs SIP transactions over net.Conns, on sipgo's transactions.

Index

Constants

This section is empty.

Variables

View Source
var CancelTimeout = 5 * time.Second

CancelTimeout bounds the CANCEL a cancelled INVITE sends.

Functions

func NewCancel

func NewCancel(invite *sip.Request) *sip.Request

NewCancel makes the CANCEL of an INVITE (RFC 3261 section 9.1).

Types

type ClientTx

type ClientTx struct {
	*sip.ClientTx
	// contains filtered or unexported fields
}

ClientTx is a client transaction.

func (*ClientTx) Responses

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

Responses returns the responses of the transaction, closed once it ends.

func (*ClientTx) Wait

func (tx *ClientTx) Wait(ctx context.Context) (*sip.Response, error)

Wait returns the final response. Cancelling the context of a ringing INVITE sends a CANCEL and waits for the final response it brings; otherwise it ends the wait.

type Layer

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

Layer runs the client and server transactions of the conns it serves.

func New

func New(log logging.LeveledLogger) *Layer

New creates a transaction layer.

func (*Layer) Do

func (l *Layer) Do(ctx context.Context, req *sip.Request, c net.Conn) (*sip.Response, error)

Do sends a request on a conn and waits for its final response.

func (*Layer) OnRequest

func (l *Layer) OnRequest(h RequestHandler)

OnRequest sets the handler of new requests.

func (*Layer) OnResponse

func (l *Layer) OnResponse(h ResponseHandler)

OnResponse sets the handler of the responses no client transaction takes.

func (*Layer) Request

func (l *Layer) Request(req *sip.Request, c net.Conn) (*ClientTx, error)

Request starts a client transaction on a conn.

func (*Layer) Serve

func (l *Layer) Serve(c net.Conn, stream bool) error

Serve reads the messages of a conn in order until it fails, then terminates its transactions. A stream carries messages framed by Content-Length, a datagram one message.

func (*Layer) Write

func (l *Layer) Write(c net.Conn, msg sip.Message) error

Write sends a message outside a transaction, such as the ACK of a 2xx.

type RequestHandler

type RequestHandler func(req *sip.Request, tx *ServerTx, conn net.Conn)

RequestHandler handles a new request in its own goroutine; tx is nil for the ACK of a 2xx.

type ResponseHandler

type ResponseHandler func(res *sip.Response, conn net.Conn)

ResponseHandler handles a response no client transaction takes. It must not block.

type ServerTx

type ServerTx struct {
	*sip.ServerTx
	// contains filtered or unexported fields
}

ServerTx is a server transaction.

func (*ServerTx) Cancelled

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

Cancelled is closed once a CANCEL ends the transaction, which then sends its 487.

Jump to

Keyboard shortcuts

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