client

package
v0.0.0-...-a857f4b Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TpUdhiSeq byte = 0x00

TpUdhiSeq tpUdhiHeader seq

Functions

This section is empty.

Types

type CMPPClient

type CMPPClient struct {
	sync.RWMutex
	*Credentials

	ID                string
	Client            *cmpp.Client
	ClientVersion     cmpp.Type
	Quit              bool
	Connected         bool
	ConnectionTimeout time.Duration
	MessageChan       chan *Message
	PingChan          chan string
	ReconnectChan     chan int
	OnConnected       func()
	OnSubmitted       func()
	OnReport          func(DeliveryReport)
	OnReply           func(Reply)

	MsgCache *ccache.Cache
	// contains filtered or unexported fields
}

CMPPClient is the key model to handel connections and message exchange with the server

func New

func New(user, password, server, id, cmppVersion string, timeout time.Duration) *CMPPClient

New will instantiate a new client with the specified login details without connecting.

func (*CMPPClient) KeepAlive

func (m *CMPPClient) KeepAlive(id int)

KeepAlive implements a ping-cycle that ensures that the connection to the chat servers remains alive.

func (*CMPPClient) Login

func (m *CMPPClient) Login() error

Login tries to connect the client with the details with which it was initialized.

func (*CMPPClient) Logout

func (m *CMPPClient) Logout() error

Logout disconnects the client from the chat server.

func (*CMPPClient) Receiver

func (m *CMPPClient) Receiver(id int)

Receiver implements the core loop that manages the connection to the chat server. In case of a disconnect it will try to reconnect. A call to this method is blocking until the 'Quit' field of the CMPPClient object is set to 'true'.

func (*CMPPClient) Run

func (m *CMPPClient) Run()

Run starts a subroutine for the cmpp client's status loop

func (*CMPPClient) SendMessage

func (m *CMPPClient) SendMessage(mobile, content, enterpriseCode, serviceCode string, validBefore time.Time, callback func(error, uint64, uint8))

SendMessage enqueue the message to the message channel

func (*CMPPClient) Sender

func (m *CMPPClient) Sender(id int)

Sender implements the core loop that sends the outbound message

func (*CMPPClient) StatusLoop

func (m *CMPPClient) StatusLoop() error

StatusLoop implements a ping-cycle that ensures that the connection to the chat servers remains alive. In case of a disconnect it will try to reconnect. A call to this method is blocking until the 'Quit' field of the CMPPClient object is set to 'true'.

type Credentials

type Credentials struct {
	Server   string
	User     string
	Password string
}

Credentials specify the credentials used for login

type DeliveryReport

type DeliveryReport struct {
	MessageID      uint64
	Status         string
	DestTerminalID string
	SmscSequence   uint32
	SubmitTime     string
	DoneTime       string
}

DeliveryReport contains the parsed info from the DeliverRequestPacket

type Message

type Message struct {
	Mobile         string
	Content        string
	EnterpriseCode string
	ServiceCode    string
	ValidBefore    time.Time
	OnResult       func(error, uint64, uint8)
}

Message is the model containing basic information to send an sms

type Reply

type Reply struct {
	MessageID     uint64
	Content       string
	SrcTerminalID string
	DestID        string
}

Reply contains the parsed info from the DeliverRequestPacket

Jump to

Keyboard shortcuts

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