use of org.jivesoftware.smack.packet.Message in project xabber-android by redsolution.
the class MUCManager method invite.
/**
* Sends invitation.
*
* @throws NetworkException
*/
public void invite(AccountJid account, EntityBareJid room, UserJid user) throws NetworkException {
RoomChat roomChat = getRoomChat(account, room);
if (roomChat == null || roomChat.getState() != RoomState.available) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
return;
}
Message message = new Message(room);
MUCUser mucUser = new MUCUser();
MUCUser.Invite invite = new MUCUser.Invite("", null, user.getBareJid().asEntityBareJidIfPossible());
mucUser.setInvite(invite);
message.addExtension(mucUser);
StanzaSender.sendStanza(account, message);
roomChat.putInvite(message.getStanzaId(), user);
roomChat.newAction(roomChat.getNickname(), user.toString(), ChatAction.invite_sent);
}
use of org.jivesoftware.smack.packet.Message in project xabber-android by redsolution.
the class SSNManager method sendFeature.
private void sendFeature(AccountJid account, Jid user, String session, Feature feature) {
Message message = new Message(user, Message.Type.normal);
message.setThread(session);
message.addExtension(feature);
try {
StanzaSender.sendStanza(account, message);
} catch (NetworkException e) {
LogManager.exception(this, e);
}
}
use of org.jivesoftware.smack.packet.Message in project xabber-android by redsolution.
the class SSNManager method onStanza.
@Override
public void onStanza(ConnectionItem connection, Stanza stanza) {
Jid from = stanza.getFrom();
if (from == null) {
return;
}
if (!(connection instanceof AccountItem) || !(stanza instanceof Message)) {
return;
}
AccountJid account = ((AccountItem) connection).getAccount();
Message message = (Message) stanza;
String session = message.getThread();
if (session == null) {
return;
}
for (ExtensionElement packetExtension : stanza.getExtensions()) {
if (packetExtension instanceof Feature) {
Feature feature = (Feature) packetExtension;
if (!feature.isValid()) {
continue;
}
DataForm.Type dataFormType = feature.getDataFormType();
if (dataFormType == DataForm.Type.form) {
onFormReceived(account, from, session, feature);
} else if (dataFormType == DataForm.Type.submit) {
onSubmitReceived(account, from, session, feature);
} else if (dataFormType == DataForm.Type.result) {
onResultReceived(account, session, feature);
}
}
}
}
use of org.jivesoftware.smack.packet.Message in project cayenne by apache.
the class XMPPBridge method sendExternalEvent.
@Override
protected void sendExternalEvent(CayenneEvent localEvent) throws Exception {
Message message = groupChat.createMessage();
message.setBody(serializeToString(localEvent));
// set thread to our session handle to be able to discard messages from self
message.setThread(sessionHandle);
groupChat.sendMessage(message);
}
use of org.jivesoftware.smack.packet.Message in project wso2-axis2-transports by wso2.
the class XMPPSender method sendChatMessage.
/**
* Replies to IM clients via a chat message. The reply contains the invocation response as a string.
* @param msgCtx
* @param responseMsg
* @throws AxisFault
*/
private static void sendChatMessage(MessageContext msgCtx, String responseMsg) throws AxisFault {
XMPPConnection xmppConnection = null;
XMPPOutTransportInfo xmppOutTransportInfo = null;
Message message = new Message();
xmppOutTransportInfo = (XMPPOutTransportInfo) msgCtx.getProperty(Constants.OUT_TRANSPORT_INFO);
if (xmppOutTransportInfo != null) {
message.setProperty(XMPPConstants.IN_REPLY_TO, xmppOutTransportInfo.getInReplyTo());
xmppConnection = xmppOutTransportInfo.getConnectionFactory().getXmppConnection();
if (xmppConnection == null) {
handleException("Connection to XMPP Server is not established.");
}
} else {
handleException("Could not find message sender details.");
}
// initialize the chat manager using connection
ChatManager chatManager = xmppConnection.getChatManager();
Chat chat = chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);
try {
message.setProperty(XMPPConstants.SEQUENCE_ID, xmppOutTransportInfo.getSequenceID());
message.setBody(responseMsg);
chat.sendMessage(message);
log.debug("Sent message :" + message.toXML());
} catch (XMPPException e) {
XMPPSender.handleException("Error occurred while sending the message : " + message.toXML(), e);
}
}
Aggregations