es/channel/index.js
function sendMessage (message, recipient) {
  let info = message
  if (typeof message === 'object') {
    info = JSON.stringify(message)
  }
  enqueueAction(
    this,
    (channel, state) => state.handler === handlers.channelOpen,
    (channel, state) => {
      send(channel, { jsonrpc: '2.0', method: 'channels.message', params: { info, to: recipient } })
      return state
    }
  )
}
function sendMessage (message, recipient) {
  let info = message
  if (typeof message === 'object') {
    info = JSON.stringify(message)
  }
  enqueueAction(
    this,
    (channel, state) => state.handler === handlers.channelOpen,
    (channel, state) => {
      send(channel, { jsonrpc: '2.0', method: 'channels.message', params: { info, to: recipient } })
      return state
    }
  )
}
function sendMessage ( message , recipient ) { let info = message if ( typeof message === 'object' ) { info = JSON . stringify ( message ) } enqueueAction ( this , ( channel , state ) => state . handler === handlers . channelOpen , ( channel , state ) => { send ( channel , { jsonrpc : '2.0' , method : 'channels.message' , params : { info , to : recipient } } ) return state } ) }
Send generic message

If message is an object it will be serialized into JSON string
before sending.

If there is ongoing update that has not yet been finished the message
will be sent after that update is finalized.

@param {String|Object} message
@param {String} recipient - Address of the recipient
@example channel.sendMessage(
'hello world',
'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH'
)
Send generic message