Documentation ¶
Index ¶
- Variables
- type CMPPClient
- func (m *CMPPClient) KeepAlive(id int)
- func (m *CMPPClient) Login() error
- func (m *CMPPClient) Logout() error
- func (m *CMPPClient) Receiver(id int)
- func (m *CMPPClient) Run()
- func (m *CMPPClient) SendMessage(mobile, content, enterpriseCode, serviceCode string, validBefore time.Time, ...)
- func (m *CMPPClient) Sender(id int)
- func (m *CMPPClient) StatusLoop() error
- type Credentials
- type DeliveryReport
- type Message
- type Reply
Constants ¶
This section is empty.
Variables ¶
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 ¶
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