ucp

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2018 License: MIT Imports: 19 Imported by: 1

README

Build Status GoDoc Coverage Status

ucp

ucp is a pure Go implementation of the UCP protocol primarily used to connect to short message service centres (SMSCs), in order to send and receive short messages (SMS).

setup
  • go 1.11
  • git
installation
go get github.com/go-gsm/ucp
usage
opt := &ucp.Options{
  Addr:       SMSC_ADDR,
  User:       SMSC_USER,
  Password:   SMSC_PASSWORD,
  AccessCode: SMSC_ACCESSCODE,
}
client := ucp.New(opt)
client.Connect()
defer client.Close()
ids, err := client.Send(sender, receiver, message)
demo

ucp-cli

demo

Documentation

Overview

Package ucp provides a UCP client.

References:

http://documents.swisscom.com/product/1000174-Internet/Documents/Landingpage-Mobile-Mehrwertdienste/UCP_R4.7.pdf
https://wiki.wireshark.org/UCP
https://www.wireshark.org/docs/dfref/u/ucp.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultHandler

func DefaultHandler(sender, receiver, messageID, message, accessCode string)

DefaultHandler is called if DeliveryHandler or ShortMessageHandler is not set. It just logs the parameters.

Types

type Client

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

Client represents a UCP client connection.

func New

func New(opt *Options) *Client

New returns a UCP client based on the given options.

func (*Client) Close

func (c *Client) Close()

Close will close the UCP connection

func (*Client) Connect

func (c *Client) Connect() error

Connect will attempt to establish a UCP connection to the SMSC.

func (*Client) DeliveryHandler

func (c *Client) DeliveryHandler(handler Handler)

DeliveryHandler sets the delivery notification handler.

func (*Client) GetBillingID

func (c *Client) GetBillingID() string

GetBillingID returns the current billing identifier.

func (*Client) GetTps

func (c *Client) GetTps() int

GetTps returns the mobile-terminating transactions per second.

func (*Client) Printf

func (c *Client) Printf(format string, v ...interface{})

Printf logs debug information to the underlying logger

func (*Client) Send

func (c *Client) Send(sender, receiver, message string) ([]string, error)

Send will send the message to the receiver with a sender mask. It returns a list of message IDs from the SMSC.

func (*Client) SetBillingID

func (c *Client) SetBillingID(id string)

SetBillingID sets the billing identifier to be used by the client.

func (*Client) SetTps

func (c *Client) SetTps(tps int)

SetTps sets the mobile-terminating transactions per second.

func (*Client) ShortMessageHandler

func (c *Client) ShortMessageHandler(handler Handler)

ShortMessageHandler sets the delivery short message handler.

type Handler

type Handler func(sender, receiver, messageID, message, accessCode string)

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

type Options

type Options struct {
	// Addr represents the ip:port address of the SMSC.
	Addr string
	// User represents the SMSC user.
	User string
	// Password represents the SMSC password.
	Password string
	// AccessCode represents the SMSC access code.
	AccessCode string
	// Tps mobile-terminating transactions per second.
	Tps int
	// Logger implements the Logger interface
	Logger Logger
	// Timeout is the specified network timeout for waiting submit short message responses
	Timeout time.Duration
	// KeepAlive is the ping interval for sending keep-alive packets to the SMSC
	KeepAlive time.Duration
	// DeliveryHandler sets the delivery notification handler(delivery receipts).
	DeliveryHandler Handler
	// ShortMessageHandler sets the delivery short message handler(mobile originating messages).
	ShortMessageHandler Handler
}

Options is used to configure the instantiation of a Client.

type UcpError

type UcpError struct {
	Code string
	Msg  string
}

UCP protocol error

func (*UcpError) Error

func (e *UcpError) Error() string

Jump to

Keyboard shortcuts

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