本文整理汇总了Java中org.jivesoftware.smackx.ChatState类的典型用法代码示例。如果您正苦于以下问题:Java ChatState类的具体用法?Java ChatState怎么用?Java ChatState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChatState类属于org.jivesoftware.smackx包,在下文中一共展示了ChatState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stateChanged
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void stateChanged(Chat chat, ChatState state) {
mState = state.name();
final int n = mRemoteListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
IMessageListener listener = mRemoteListeners.getBroadcastItem(i);
try {
listener.stateChanged(ChatAdapter.this);
} catch (RemoteException e) {
Log.w(TAG, e.getMessage());
}
}
mRemoteListeners.finishBroadcast();
}
示例2: closeChatRoom
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void closeChatRoom() {
// If already closed, don't bother.
if (!active) {
return;
}
super.closeChatRoom();
removeListeners();
sendChatState(ChatState.gone);
sendGoneNotification = false;
SparkManager.getChatManager().removeChat(this);
SparkManager.getConnection().removePacketListener(this);
if (typingTimerTask != null) {
TaskEngine.getInstance().cancelScheduledTask(typingTimerTask);
typingTimerTask = null;
}
active = false;
vcardPanel = null;
this.removeAll();
}
示例3: insertUpdate
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
* The current SendField has been updated somehow.
*
* @param e - the DocumentEvent to respond to.
*/
public void insertUpdate(DocumentEvent e) {
checkForText(e);
if (!sendChatStateNotification) {
return;
}
startNotificationSendingTime = System.currentTimeMillis();
// If the user pauses for more than two seconds, send out a new notice.
if (sendComposingNotification) {
try {
//SparkManager.getMessageEventManager().sendComposingNotification(getParticipantJID(), threadID);
sendChatState(ChatState.composing);
sendPausingNotification = true;
sendInactiveNotification = true;
sendGoneNotification = true;
sendComposingNotification = false;
}
catch (Exception exception) {
Log.error("Error updating", exception);
}
}
}
示例4: filterIncomingMessage
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
* Filters all incoming messages.
*
* @param room the room the message belongs to.
* @param message the message to filter.
*/
public void filterIncomingMessage(ChatRoom room, Message message) {
// Fire Message Filters
final ChatManager chatManager = SparkManager.getChatManager();
Iterator<MessageFilter> filters = chatManager.getMessageFilters().iterator();
try {
cancelledNotification(message.getFrom(), ChatState.paused);
}
catch (Exception e) {
Log.error(e);
}
// Notify MessageFilters.
while (filters.hasNext()) {
(filters.next()).filterIncoming(room, message);
}
}
示例5: composingNotification
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void composingNotification(final String from) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final ContactList contactList = SparkManager.getWorkspace().getContactList();
ChatRoom chatRoom;
try {
chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
typingNotificationList.add(chatRoom);
// Notify Decorators
notifySparkTabHandlers(chatRoom);
((ChatRoomImpl)chatRoom).notifyChatStateChange(ChatState.composing);
}
}
catch (ChatRoomNotFoundException e) {
// Do nothing
}
contactList.setIconFor(from, SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_EDIT_IMAGE));
}
});
}
示例6: cancelledNotification
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void cancelledNotification(final String from, final ChatState state) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ContactList contactList = SparkManager.getWorkspace().getContactList();
ChatRoom chatRoom;
try {
chatRoom = getChatContainer().getChatRoom(StringUtils.parseBareAddress(from));
if (chatRoom != null && chatRoom instanceof ChatRoomImpl) {
typingNotificationList.remove(chatRoom);
// Notify Decorators
notifySparkTabHandlers(chatRoom);
((ChatRoomImpl)chatRoom).notifyChatStateChange(state);
}
}
catch (ChatRoomNotFoundException e) {
// Do nothing
}
contactList.useDefaults(from);
}
});
}
示例7: parseExtension
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
ChatState state;
try {
state = ChatState.valueOf(parser.getName());
}
catch (Exception ex) {
state = ChatState.active;
}
return new ChatStateExtension(state);
}
示例8: parseExtension
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public PacketExtension parseExtension(XmlPullParser parser)
throws Exception {
ChatState state;
try {
state = ChatState.valueOf(parser.getName());
} catch (Exception ex) {
state = ChatState.active;
}
return new ChatStateExtension(state);
}
示例9: sendChatState
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
/**
* @see net.sf.kraken.session.TransportSession#sendChatState(org.xmpp.packet.JID, net.sf.kraken.type.ChatStateType)
*/
@Override
public void sendChatState(JID jid, ChatStateType chatState) {
final Presence presence = conn.getRoster().getPresence(jid.toString());
if (presence == null || presence.getType().equals(Presence.Type.unavailable)) {
// don't send chat state to contacts that are offline.
return;
}
Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
try {
ChatState state = ChatState.active;
switch (chatState) {
case active: state = ChatState.active; break;
case composing: state = ChatState.composing; break;
case paused: state = ChatState.paused; break;
case inactive: state = ChatState.inactive; break;
case gone: state = ChatState.gone; break;
}
Message message = new Message();
message.addExtension(new ChatStateExtension(state));
chat.sendMessage(message);
}
catch (XMPPException e) {
// Ignore
}
}
示例10: createChatStateTimerTask
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
protected void createChatStateTimerTask() {
typingTimerTask = new TimerTask() {
public void run() {
if (!sendChatStateNotification) {
return;
}
long now = System.currentTimeMillis();
long time = now - startNotificationSendingTime;
if (inBetween(time, pauseTimePeriod, inactiveTimePeriod)) {
if (sendPausingNotification) {
// send cancel
//SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID);
sendChatState(ChatState.paused);
sendPausingNotification = false;
sendComposingNotification = true;
}
} else if (inBetween(time, inactiveTimePeriod, goneTimePeriod)) {
if(sendInactiveNotification) {
sendChatState(ChatState.inactive);
sendInactiveNotification = false;
}
} else if (time > goneTimePeriod) {
if (sendGoneNotification) {
sendChatState(ChatState.gone);
sendGoneNotification = false;
}
}
}
};
TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, pauseTimePeriod, pauseTimePeriod);
}
示例11: activateChatStateNotificationSystem
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void activateChatStateNotificationSystem() {
startNotificationSendingTime = System.currentTimeMillis();
sendInactiveNotification = true;
sendGoneNotification = true;
sendPausingNotification = false;
sendComposingNotification = true;
if (lastNotificationSent == null || !lastNotificationSent.equals(ChatState.active)) {
sendChatState(ChatState.active);
}
}
示例12: inactivateChatStateNotificationSystem
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void inactivateChatStateNotificationSystem() {
startNotificationSendingTime = System.currentTimeMillis();
sendInactiveNotification = false;
sendGoneNotification = true;
sendPausingNotification = false;
sendComposingNotification = false;
if (lastNotificationSent != null && !lastNotificationSent.equals(ChatState.inactive) && !lastNotificationSent.equals(ChatState.gone)) {
sendChatState(ChatState.inactive);
}
}
示例13: sendChatState
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
private void sendChatState(ChatState state) {
Connection connection = SparkManager.getConnection();
boolean connected = connection.isConnected();
if (connected) {
Chat chat = connection.getChatManager().createChat(getParticipantJID(), null);
try {
ChatStateManager.getInstance(connection).setCurrentState(state, chat);
lastNotificationSent = state;
} catch (XMPPException e) {
Log.error("Cannot send " + state + " chat notification");
}
}
}
示例14: notifyChatStateChange
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public void notifyChatStateChange(ChatState state) {
if (chatStatePanel != null) {
getEditorWrapperBar().remove(chatStatePanel);
}
chatStatePanel = new ChatStatePanel(state, getParticipantNickname());
getEditorWrapperBar().add(chatStatePanel, BorderLayout.SOUTH);
getEditorWrapperBar().revalidate();
getEditorWrapperBar().repaint();
}
示例15: ChatStatePanel
import org.jivesoftware.smackx.ChatState; //导入依赖的package包/类
public ChatStatePanel(ChatState state, String nickname) {
setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
label = new JLabel(Res.getString(state.name(), nickname));
label.setFont(new Font("Courier New", Font.PLAIN, 9));
label.setForeground(Color.gray);
label.setHorizontalTextPosition(JLabel.LEFT);
label.setVerticalTextPosition(JLabel.BOTTOM);
add(label);
}