message

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package message provides a higher level abstraction of message which is passed via SMS TPDUs, either singly or as a set of concatenated TPDUs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector interface {
	Collect(pdu *tpdu.Deliver) ([]*tpdu.Deliver, error)
	Close()
}

Collector collects the segments of a concatenated SMS and returns the completed set when available.

type Concatenator

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

Concatenator converts a set of concatenated TPDUs into a Message.

func NewConcatenator

func NewConcatenator(d DataDecoder) *Concatenator

NewConcatenator creates a new Concatenator.

func (*Concatenator) Concatenate

func (c *Concatenator) Concatenate(segments []*tpdu.Deliver) (*Message, error)

Concatenate converts a set of concatenated TPDUs into a Message. The User Data in each TPDU is converted to UTF-8 using the DataDecoder.

type DataDecoder

type DataDecoder interface {
	Decode(ud tpdu.UserData, udh tpdu.UserDataHeader, alpha tpdu.Alphabet) ([]byte, error)
}

DataDecoder provides a Decode method to convert the user data from a TPDU into the corresponding UTF-8 message.

type DataEncoder

type DataEncoder interface {
	Encode(msg string) (tpdu.UserData, tpdu.UserDataHeader, tpdu.Alphabet, error)
}

DataEncoder converts a UTF-8 message into the corresponding TPDU user data.

type Encoder

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

Encoder builds Submit TPDUs from simple inputs such as the destination number and the message in a UTF8 form.

func NewEncoder

func NewEncoder(e DataEncoder, s Segmenter) *Encoder

NewEncoder creates an Encoder.

func (*Encoder) Encode

func (e *Encoder) Encode(number, msg string) ([]tpdu.Submit, error)

Encode builds a set of Submit TPDUs from the destination number and UTF8 message. Long messages are split into multiple concatenated TPDUs, while short messages may fit in one.

func (*Encoder) Encode8Bit

func (e *Encoder) Encode8Bit(number string, d []byte) ([]tpdu.Submit, error)

Encode8Bit builds a set of Submit TPDUs from the destination number and raw binary message. Long messages are split into multiple concatenated TPDUs, while short messages may fit in one.

func (*Encoder) SetT

func (e *Encoder) SetT(t *tpdu.Submit)

SetT sets the template Submit TPDU used by Encode. The Submit TPDU is used to populate the fields for encoded Submit TPDUs, with the exception of the MR, DA and UD which are explicitly set by Encode. Encode also sets the DCS alphabet, and may add elements to the UDH. The provided DCS may contain a message class, but will be completely ignored if the value is incompatible with setting the alphabet.

type Message

type Message struct {
	Msg    string
	Number string
	TPDUs  []*tpdu.Deliver
}

Message represents a message received from an origination number. The message is provided in UTF8. The message was contained in the associated TPDUs.

type Reassembler

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

Reassembler is responsible for collecting TPDUs and building Messages from them using the DataDecoder (typically a tpdu.UDDecoder).

func NewReassembler

func NewReassembler(d DataDecoder, c Collector) *Reassembler

NewReassembler creates a Reassembler.

func (*Reassembler) Close

func (r *Reassembler) Close()

Close terminates the reassembler and all the reassembly pipes currently active.

func (*Reassembler) Reassemble

func (r *Reassembler) Reassemble(b []byte) (*Message, error)

Reassemble takes a binary Deliver TPDU and adds it to the reassembly collection. If the Deliver is the last TPDU in a set then the completed Message is returned.

type Segmenter

type Segmenter interface {
	Segment(msg []byte, t *tpdu.Submit) []tpdu.Submit
}

Segmenter segments a large outgoing message into the set of Submit TPDUs required to contain it.

Jump to

Keyboard shortcuts

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