+func (m *RMRClient) Send(params *RMRParams, isRts bool) C.int {
+ txBuffer := params.Mbuf
+ if txBuffer == nil {
+ txBuffer = m.Allocate()
+ }
+
+ txBuffer.mtype = C.int(params.Mtype)
+ txBuffer.sub_id = C.int(params.SubId)
+ txBuffer.len = C.int(len(params.Payload))
+ if params.PayloadLen != 0 {
+ txBuffer.len = C.int(params.PayloadLen)
+ }
+ datap := C.CBytes(params.Payload)
+ defer C.free(datap)
+
+ if params != nil {
+ if params.Meid != nil {
+ b := make([]byte, int(C.RMR_MAX_MEID))
+ copy(b, []byte(params.Meid.RanName))
+ C.rmr_bytes2meid(txBuffer, (*C.uchar)(unsafe.Pointer(&b[0])), C.int(len(b)))
+ }
+ xidLen := len(params.Xid)
+ if xidLen > 0 && xidLen <= C.RMR_MAX_XID {
+ b := make([]byte, int(C.RMR_MAX_MEID))
+ copy(b, []byte(params.Xid))
+ C.rmr_bytes2xact(txBuffer, (*C.uchar)(unsafe.Pointer(&b[0])), C.int(len(b)))
+ }
+ }
+ C.write_bytes_array(txBuffer.payload, datap, txBuffer.len)
+
+ txBuffer.state = 0
+ currBuffer := txBuffer
+ if isRts {
+ currBuffer = C.rmr_rts_msg(m.context, txBuffer)
+ } else {
+ currBuffer = C.rmr_send_msg(m.context, txBuffer)
+ }
+
+ if currBuffer != nil {
+ return currBuffer.state
+ }
+ return -1
+}
+