server

package
v0.0.0-...-94275f6 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	UserName string `valid:"required"`
	Password string `valid:"required"`
}

type Conn

type Conn interface {
	// Write serializes the given PDU and writes to the connection.
	Write(p pdu.Body) error

	// Close terminates the connection.
	Close() error

	// RemoteAddr returns the peer address.
	RemoteAddr() net.Addr
}

Conn implements a server side connection.

type HandlerFunc

type HandlerFunc func(c Conn, submit *message.ShortMessage) (*message.ShortMessageResp, error)

HandlerFunc is the signature of a function passed to Server instances, that is called when client PDU messages arrive.

type Server

type Server struct {
	Accounts map[string]Account
	SystemID string `valid:"required"`
	Port     int    `valid:"required"`
	TLS      *tls.Config
	Handler  HandlerFunc
	// contains filtered or unexported fields
}

Server is an SMPP server.

func NewServer

func NewServer(systemID string, port int, handler HandlerFunc) *Server

func (*Server) AddAccount

func (server *Server) AddAccount(account *Account)

func (*Server) Addr

func (srv *Server) Addr() string

Addr returns the local address of the server, or an empty string if the server hasn't been started yet.

func (*Server) Close

func (srv *Server) Close()

Close stops the server, causing the accept loop to break out.

func (*Server) Serve

func (srv *Server) Serve()

Serve accepts new clients and handle them by authenticating the first PDU, expected to be a Bind PDU. Other PDUs will be handled by the Handler function defined for the server

func (*Server) Start

func (srv *Server) Start()

Start starts the server.

Jump to

Keyboard shortcuts

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