Documentation
¶
Index ¶
- Constants
- type Connection
- func (c *Connection) GetAddress() string
- func (c *Connection) GetReceiveTimeout() int64
- func (c *Connection) GetSendTimeout() int64
- func (c *Connection) SetAddress(addr string)
- func (c *Connection) SetDefault()
- func (c *Connection) SetReceiveTimeout(t int64)
- func (c *Connection) SetSendTimeout(t int64)
- type IConnection
- type IReceiver
- type ReceivedPDUEvent
- type Receiver
- func (c *Receiver) Receive()
- func (c *Receiver) ReceivePDUFromConnection(conn IConnection, unprocessed *Utils.Unprocessed) (PDU.IPDU, *Exception.Exception)
- func (c *Receiver) ReceiveSyncWTimeout(timeout int64) (PDU.IPDU, *Exception.Exception)
- func (c *Receiver) ReceiveSyncWithExpectedPDU(pdu PDU.IPDU) (PDU.IPDU, *Exception.Exception)
- func (c Receiver) SetReceiveTimeout(timeout int64)
- func (c *Receiver) Start()
- func (c *Receiver) Stop()
- func (c *Receiver) StopByException(e *Exception.Exception)
- func (c *Receiver) TryReceivePDU(conn IConnection, expected PDU.IPDU) (pduResult PDU.IPDU, expc *Exception.Exception)
- type ServerPDUEvent
- type ServerPDUEventListener
- type Session
- func (c *Session) AlertNotification(req *PDU.AlertNotification) (err *Exception.Exception)
- func (c *Session) Bind(req PDU.IBindRequest) (PDU.IResponse, *Exception.Exception)
- func (c *Session) BindWithListener(req PDU.IBindRequest, pduListener ServerPDUEventListener) (bindResp PDU.IResponse, err *Exception.Exception)
- func (c *Session) Cancel(req *PDU.CancelSM) (resp *PDU.CancelSMResp, err *Exception.Exception)
- func (c *Session) CheckPDUState(pdu PDU.IPDU) *Exception.Exception
- func (c *Session) CheckState(requestedState int32) *Exception.Exception
- func (c *Session) Close() *Exception.Exception
- func (c *Session) Data(req *PDU.DataSM) (resp *PDU.DataSMResp, err *Exception.Exception)
- func (c *Session) Deliver(req *PDU.DeliverSM) (resp *PDU.DeliverSMResp, err *Exception.Exception)
- func (c *Session) DisableStateChecking()
- func (c *Session) DoEnquireLink() (resp *PDU.EnquireLinkResp, err *Exception.Exception)
- func (c *Session) EnableStateChecking()
- func (c *Session) EnquireLink(req *PDU.EnquireLink) (resp *PDU.EnquireLinkResp, err *Exception.Exception)
- func (c *Session) GenericNack(resp *PDU.GenericNack) *Exception.Exception
- func (c *Session) GenericNackWithCmStatusSeqNum(commandStatus, sequenceNumber int32) *Exception.Exception
- func (c *Session) GetConnection() IConnection
- func (c *Session) GetReceiver() *Receiver
- func (c *Session) GetState() int32
- func (c *Session) GetTransmitter() *Transmitter
- func (c *Session) GetType() int32
- func (c *Session) IsBound() bool
- func (c *Session) IsOpened() bool
- func (c *Session) IsPDUAllowed(pdu PDU.IPDU) bool
- func (c *Session) IsStateAllowed(requestedState int32) bool
- func (c *Session) Open() *Exception.Exception
- func (c *Session) Query(req *PDU.QuerySM) (resp *PDU.QuerySMResp, err *Exception.Exception)
- func (c *Session) Receive() (pdu PDU.IPDU, err *Exception.Exception)
- func (c *Session) ReceiveWTimeout(timeout int64) (pdu PDU.IPDU, err *Exception.Exception)
- func (c *Session) Replace(req *PDU.ReplaceSM) (resp *PDU.ReplaceSMResp, err *Exception.Exception)
- func (c *Session) Respond(resp PDU.IResponse) (err *Exception.Exception)
- func (c *Session) Send(req PDU.IRequest) (resp PDU.IResponse, err *Exception.Exception)
- func (c *Session) SendAsync(req PDU.IRequest, isAsync bool) (resp PDU.IResponse, err *Exception.Exception)
- func (c *Session) SetType(t int32)
- func (c *Session) Submit(req *PDU.SubmitSM) (resp *PDU.SubmitSMResp, err *Exception.Exception)
- func (c *Session) SubmitMulti(req *PDU.SubmitMultiSM) (resp *PDU.SubmitMultiSMResp, err *Exception.Exception)
- func (c *Session) Unbind() (unbindResp *PDU.UnbindResp, err *Exception.Exception)
- type SocketFactory
- type TCPIPConnection
- func (c *TCPIPConnection) Close() *Exception.Exception
- func (c *TCPIPConnection) IsOpened() bool
- func (c *TCPIPConnection) Open() *Exception.Exception
- func (c *TCPIPConnection) Receive() (result *Utils.ByteBuffer, err *Exception.Exception)
- func (c *TCPIPConnection) Send(data *Utils.ByteBuffer) (err *Exception.Exception)
- func (c *TCPIPConnection) SetIOBufferSize(size int)
- func (c *TCPIPConnection) SetMaxReceiveSize(size int)
- func (c *TCPIPConnection) SetReceiveBufferSize(size int)
- type Transmitter
- type UnbindServerPDUEventListener
- func (c *UnbindServerPDUEventListener) GetUnbindResp() *PDU.UnbindResp
- func (c *UnbindServerPDUEventListener) HandleEvent(event *ServerPDUEvent) *Exception.Exception
- func (c *UnbindServerPDUEventListener) HandleException(err *Exception.Exception)
- func (c *UnbindServerPDUEventListener) StartWait(miliSecond int64)
Constants ¶
const ( RECEIVER_THREAD_NAME = "Receiver" RECEIVE_CHAN_SIZE = 10000 )
const ( STATE_NOT_ALLOWED int32 = 0x00 STATE_CLOSED int32 = 0x01 STATE_OPENED int32 = 0x02 STATE_TRANSMITTER int32 = 0x04 STATE_RECEIVER int32 = 0x08 STATE_TRANSCEIVER int32 = 0x10 STATE_ALWAYS int32 = STATE_OPENED | STATE_TRANSMITTER | STATE_RECEIVER | STATE_TRANSCEIVER TYPE_ESME int32 = 1 TYPE_MC int32 = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func (*Connection) GetAddress ¶
func (c *Connection) GetAddress() string
func (*Connection) GetReceiveTimeout ¶
func (c *Connection) GetReceiveTimeout() int64
func (*Connection) GetSendTimeout ¶
func (c *Connection) GetSendTimeout() int64
func (*Connection) SetAddress ¶
func (c *Connection) SetAddress(addr string)
func (*Connection) SetDefault ¶
func (c *Connection) SetDefault()
func (*Connection) SetReceiveTimeout ¶
func (c *Connection) SetReceiveTimeout(t int64)
func (*Connection) SetSendTimeout ¶
func (c *Connection) SetSendTimeout(t int64)
type IConnection ¶
type IConnection interface {
SetReceiveTimeout(t int64)
GetReceiveTimeout() int64
SetSendTimeout(t int64)
GetSendTimeout() int64
SetAddress(addr string)
GetAddress() string
Open() *Exception.Exception
IsOpened() bool
Close() *Exception.Exception
Send(data *Utils.ByteBuffer) *Exception.Exception
Receive() (*Utils.ByteBuffer, *Exception.Exception)
}
IConnection smpp connection interface
type ReceivedPDUEvent ¶
type ReceivedPDUEvent struct {
Connection IConnection
Pdu PDU.IPDU
Source interface{}
// contains filtered or unexported fields
}
func NewReceivedPDUEvent ¶
func NewReceivedPDUEvent(source *receiverBase, con IConnection, pdu PDU.IPDU) *ReceivedPDUEvent
func (*ReceivedPDUEvent) GetConnection ¶
func (c *ReceivedPDUEvent) GetConnection() IConnection
func (*ReceivedPDUEvent) GetPDU ¶
func (c *ReceivedPDUEvent) GetPDU() PDU.IPDU
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
func NewReceiver ¶
func NewReceiver(listener ServerPDUEventListener) (r *Receiver)
func NewReceiverWithConnection ¶
func NewReceiverWithConnection(listener ServerPDUEventListener, conn IConnection) (r *Receiver)
func NewReceiverWithTransmitterCon ¶
func NewReceiverWithTransmitterCon(listener ServerPDUEventListener, trans *Transmitter, conn IConnection) (r *Receiver)
func (*Receiver) Receive ¶ added in v0.1.1
func (c *Receiver) Receive()
*
- This method receives a PDU from connection and stores it into
- <code>pduQueue</code>. It's called from the <code>ReceiverBase</code>'s
- p<code>process</code> method which is called in loop from
- <code>ProcessingThread</code>'s <code>run</code> method.
- <p>
- If an exception occurs during receiving, depending on type
- of the exception this method either just reports the exception to
- debug & event objects or stops processing to indicate
- that it isn't able to process the exception. The function
- <code>setTermException</code> is then called with the caught exception. *
- @see ReceiverBase#run()
func (*Receiver) ReceivePDUFromConnection ¶ added in v0.1.1
func (c *Receiver) ReceivePDUFromConnection(conn IConnection, unprocessed *Utils.Unprocessed) (PDU.IPDU, *Exception.Exception)
func (*Receiver) ReceiveSyncWTimeout ¶
*
- This method receives a PDU or returns PDU received on background,
- if there is any. It tries to receive a PDU for the specified timeout.
- If the receiver is asynchronous, then no attempt to receive a PDU
- and <code>null</code> is returned.
- The function calls are nested as follows:<br>
- <ul>
- <li>No background receiver thread<br><code>
- Receiver.receive(long)<br>
- ReceiverBase.tryReceivePDUWithTimeout(Connection,PDU,long)<br>
- Receiver.tryReceivePDU(Connection,PDU)<br>
- ReceiverBase.receivePDUFromConnection<br>
- Connection.receive()</code>
- <li>Has background receiver thread<br><code>
- Receiver.receive(long)<br>
- ReceiverBase.tryReceivePDUWithTimeout(Connection,PDU,long)<br>
- Receiver.tryReceivePDU(Connection,PDU)<br>
- Queue.dequeue(PDU)</code><br>
- and the ReceiverBase.run() function which actually receives the
- PDUs and stores them to a queue looks as follows:<br><code>
- ReceiverBase.run()<br>
- Receiver.receiveAsync()<br>
- ReceiverBase.receivePDUFromConnection<br>
- Connection.receive()</code> *
- @param timeout for how long is tried to receive a PDU
- @return the received PDU or null if none received for the spec. timeout *
- @exception IOException exception during communication
- @exception PDUException incorrect format of PDU
- @exception TimeoutException rest of PDU not received for too long time
- @exception UnknownCommandIdException PDU with unknown id was received
- @see ReceiverBase#tryReceivePDUWithTimeout(Connection,PDU,long)
func (*Receiver) ReceiveSyncWithExpectedPDU ¶
*
- Called from session to receive a response for previously sent request. *
- @param expectedPDU the template for expected PDU; the PDU returned
- must have the same sequence number
- @return the received PDU or null if none
- @see ReceiverBase#tryReceivePDUWithTimeout(Connection,PDU,long)
func (Receiver) SetReceiveTimeout ¶ added in v0.1.2
func (c Receiver) SetReceiveTimeout(timeout int64)
func (*Receiver) Start ¶
func (c *Receiver) Start()
Start will reset unprocessed data and start receiving on the background.
func (*Receiver) StopByException ¶
StopByException stops receiver and print err log.
func (*Receiver) TryReceivePDU ¶
type ServerPDUEvent ¶
type ServerPDUEvent struct {
ReceivedPDUEvent
}
func NewServerPDUEvent ¶
func NewServerPDUEvent(source *Receiver, con IConnection, pdu PDU.IPDU) *ServerPDUEvent
func (*ServerPDUEvent) GetReceiver ¶
func (c *ServerPDUEvent) GetReceiver() *Receiver
type ServerPDUEventListener ¶
type ServerPDUEventListener interface {
HandleEvent(event *ServerPDUEvent) *Exception.Exception
HandleException(*Exception.Exception)
}
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSessionWithConnection ¶
func NewSessionWithConnection(conn IConnection) *Session
func (*Session) AlertNotification ¶
func (c *Session) AlertNotification(req *PDU.AlertNotification) (err *Exception.Exception)
func (*Session) BindWithListener ¶
func (c *Session) BindWithListener(req PDU.IBindRequest, pduListener ServerPDUEventListener) (bindResp PDU.IResponse, err *Exception.Exception)
func (*Session) CheckState ¶
func (*Session) DisableStateChecking ¶
func (c *Session) DisableStateChecking()
func (*Session) DoEnquireLink ¶
func (c *Session) DoEnquireLink() (resp *PDU.EnquireLinkResp, err *Exception.Exception)
func (*Session) EnableStateChecking ¶
func (c *Session) EnableStateChecking()
func (*Session) EnquireLink ¶
func (c *Session) EnquireLink(req *PDU.EnquireLink) (resp *PDU.EnquireLinkResp, err *Exception.Exception)
func (*Session) GenericNack ¶
func (c *Session) GenericNack(resp *PDU.GenericNack) *Exception.Exception
func (*Session) GenericNackWithCmStatusSeqNum ¶
func (*Session) GetConnection ¶
func (c *Session) GetConnection() IConnection
func (*Session) GetReceiver ¶
func (*Session) GetTransmitter ¶
func (c *Session) GetTransmitter() *Transmitter
func (*Session) IsStateAllowed ¶
func (*Session) ReceiveWTimeout ¶
func (*Session) SubmitMulti ¶
func (c *Session) SubmitMulti(req *PDU.SubmitMultiSM) (resp *PDU.SubmitMultiSMResp, err *Exception.Exception)
type SocketFactory ¶
type SocketFactory struct {
}
type TCPIPConnection ¶
type TCPIPConnection struct {
Connection
// contains filtered or unexported fields
}
func NewTCPIPConnection ¶
func NewTCPIPConnection() *TCPIPConnection
NewTCPIPConnection new tcp ip connection
func NewTCPIPConnectionWithAddrPort ¶
func NewTCPIPConnectionWithAddrPort(addr string, port int) (*TCPIPConnection, error)
NewTCPIPConnectionWithAddrPort new tcp/ip connection with addr and port
func NewTCPIPConnectionWithSocket ¶
func NewTCPIPConnectionWithSocket(soc *net.TCPConn) (*TCPIPConnection, error)
NewTCPIPConnectionWithSocket new tcp/ip connection with preallocated socket. Useful for tls enabled connection.
func (*TCPIPConnection) Close ¶
func (c *TCPIPConnection) Close() *Exception.Exception
Close connection
func (*TCPIPConnection) IsOpened ¶
func (c *TCPIPConnection) IsOpened() bool
IsOpened check if connection is opened
func (*TCPIPConnection) Open ¶
func (c *TCPIPConnection) Open() *Exception.Exception
Open connection
func (*TCPIPConnection) Receive ¶
func (c *TCPIPConnection) Receive() (result *Utils.ByteBuffer, err *Exception.Exception)
Receive message from connection in form of buffer
func (*TCPIPConnection) Send ¶
func (c *TCPIPConnection) Send(data *Utils.ByteBuffer) (err *Exception.Exception)
Send buffered data
func (*TCPIPConnection) SetIOBufferSize ¶
func (c *TCPIPConnection) SetIOBufferSize(size int)
SetIOBufferSize set io buffer size
func (*TCPIPConnection) SetMaxReceiveSize ¶
func (c *TCPIPConnection) SetMaxReceiveSize(size int)
SetMaxReceiveSize set max length of message allowed to receive over socket
func (*TCPIPConnection) SetReceiveBufferSize ¶
func (c *TCPIPConnection) SetReceiveBufferSize(size int)
SetReceiveBufferSize set buffer size for receiving message over socket
type Transmitter ¶
type Transmitter struct {
// contains filtered or unexported fields
}
func NewTransmitter ¶
func NewTransmitter() *Transmitter
func NewTransmitterWithConnection ¶
func NewTransmitterWithConnection(con IConnection) *Transmitter
type UnbindServerPDUEventListener ¶
type UnbindServerPDUEventListener struct {
// contains filtered or unexported fields
}
func NewUnbindServerPDUEventListener ¶
func NewUnbindServerPDUEventListener(sess *Session, origListener ServerPDUEventListener, unbindReq *PDU.Unbind) *UnbindServerPDUEventListener
func (*UnbindServerPDUEventListener) GetUnbindResp ¶
func (c *UnbindServerPDUEventListener) GetUnbindResp() *PDU.UnbindResp
func (*UnbindServerPDUEventListener) HandleEvent ¶
func (c *UnbindServerPDUEventListener) HandleEvent(event *ServerPDUEvent) *Exception.Exception
func (*UnbindServerPDUEventListener) HandleException ¶ added in v0.1.3
func (c *UnbindServerPDUEventListener) HandleException(err *Exception.Exception)
func (*UnbindServerPDUEventListener) StartWait ¶
func (c *UnbindServerPDUEventListener) StartWait(miliSecond int64)