void _Say(ChatModel chat, string text, bool send, bool display)
{
if (!chat.IsEnabled) {
return;
}
if (chat == ContactChat) {
return;
}
if (send) {
if (chat.ChatType == ChatType.Person) {
var _person = (chat as PersonChatModel).Person as PersonModel;
XmppPersonModel person = GetOrCreateContact(_person.ID, _person.IdentityName);
SendPrivateMessage(person, _person.ID, text);
} else if (chat.ChatType == ChatType.Group) {
JabberClient.Send(new Message(chat.ID, XmppMessageType.groupchat, text));
return; // don't show now. the message will be echoed back if it's sent successfully
}
}
var builder = CreateMessageBuilder();
builder.AppendSenderPrefix(Me);
builder.AppendMessage(text);
var msg = builder.ToMessage();
if (display) {
Session.AddMessageToChat(chat, msg);
}
OnMessageSent(
new MessageEventArgs(chat, msg, null, chat.ID)
);
}