Search in sources :

Example 1 with ChatRoomOpeningListener

use of battleship.listener.ChatRoomOpeningListener in project Spark by igniterealtime.

the class BattleshipPlugin method initialize.

@Override
public void initialize() {
    ProviderManager.addIQProvider(GameOfferPacket.ELEMENT_NAME, GameOfferPacket.NAMESPACE, GameOfferPacket.class);
    ProviderManager.addExtensionProvider(MovePacket.ELEMENT_NAME, MovePacket.NAMESPACE, MovePacket.class);
    ProviderManager.addExtensionProvider(MoveAnswerPacket.ELEMENT_NAME, MoveAnswerPacket.NAMESPACE, MoveAnswerPacket.class);
    _gameofferListener = new StanzaListener() {

        @Override
        public void processPacket(Stanza stanza) {
            GameOfferPacket invitation = (GameOfferPacket) stanza;
            if (invitation.getType() == IQ.Type.get) {
                showInvitationInChat(invitation);
            }
        }
    };
    SparkManager.getConnection().addAsyncStanzaListener(_gameofferListener, new StanzaTypeFilter(GameOfferPacket.class));
    _chatRoomListener = new ChatRoomOpeningListener();
    SparkManager.getChatManager().addChatRoomListener(_chatRoomListener);
}
Also used : StanzaTypeFilter(org.jivesoftware.smack.filter.StanzaTypeFilter) GameOfferPacket(battleship.packets.GameOfferPacket) Stanza(org.jivesoftware.smack.packet.Stanza) StanzaListener(org.jivesoftware.smack.StanzaListener) ChatRoomOpeningListener(battleship.listener.ChatRoomOpeningListener)

Aggregations

ChatRoomOpeningListener (battleship.listener.ChatRoomOpeningListener)1 GameOfferPacket (battleship.packets.GameOfferPacket)1 StanzaListener (org.jivesoftware.smack.StanzaListener)1 StanzaTypeFilter (org.jivesoftware.smack.filter.StanzaTypeFilter)1 Stanza (org.jivesoftware.smack.packet.Stanza)1