sendMessage method
Implementation
void sendMessage(String target, String text) {
final acc = _account;
if (acc == null) return;
final targetUri = _normaliseTarget(target, acc.domain);
final callId = _uuid.v4();
final msg = _buildRequest(
method: 'MESSAGE',
requestUri: targetUri,
callId: callId,
fromTag: _shortTag(),
cseq: _nextCseq(),
branch: _branch(),
target: targetUri,
account: acc,
extra: {'Content-Type': 'text/plain'},
body: text,
);
_send(msg);
// Echo the outbound message into the message stream so that UIs which
// render two-sided threads can show the sent line immediately.
_messageCtl.add(
SipTextMessage(
from: acc.aor,
to: targetUri,
body: text,
receivedAt: DateTime.now(),
outgoing: true,
),
);
}