当前位置: 首页>>代码示例>>Java>>正文


Java DataForm.getType方法代码示例

本文整理汇总了Java中org.xmpp.forms.DataForm.getType方法的典型用法代码示例。如果您正苦于以下问题:Java DataForm.getType方法的具体用法?Java DataForm.getType怎么用?Java DataForm.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmpp.forms.DataForm的用法示例。


在下文中一共展示了DataForm.getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleDataFormElement

import org.xmpp.forms.DataForm; //导入方法依赖的package包/类
/**
 * Handles packets that includes a data form. The data form was sent using an element with name
 * "x" and namespace "jabber:x:data".
 *
 * @param senderRole  the role of the user that sent the data form.
 * @param formElement the element that contains the data form specification.
 * @throws ForbiddenException    if the user does not have enough privileges.
 * @throws ConflictException If the room was going to lose all of its owners.
 */
private void handleDataFormElement(MUCRole senderRole, Element formElement)
        throws ForbiddenException, ConflictException, NotAcceptableException {
    DataForm completedForm = new DataForm(formElement);

    switch(completedForm.getType()) {
    case cancel:
        // If the room was just created (i.e. is locked) and the owner cancels the configuration
        // form then destroy the room
        if (room.isLocked()) {
            room.destroyRoom(null, null);
        }
        break;
        
    case submit:
        // The owner is requesting an instant room
        if (completedForm.getFields().isEmpty()) {
            // Do nothing
        }
        // The owner is requesting a reserved room or is changing the current configuration
        else {
            processConfigurationForm(completedForm, senderRole);
        }
        // If the room was locked, unlock it and send to the owner the "room is now unlocked"
        // message
        if (room.isLocked() && !room.isManuallyLocked()) {
            room.unlock(senderRole);
        }
        if (!room.isDestroyed) {
            // Let other cluster nodes that the room has been updated
            CacheFactory.doClusterTask(new RoomUpdatedEvent(room));
        }
        break;
        
    default:
        Log.warn("cannot handle data form element: " + formElement.asXML());
        break;
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:48,代码来源:IQOwnerHandler.java

示例2: process

import org.xmpp.forms.DataForm; //导入方法依赖的package包/类
/**
 * Handles Message packets sent to the pubsub service. Messages may be of type error
 * when an event notification was sent to a susbcriber whose address is no longer available.<p>
 *
 * Answers to authorization requests sent to node owners to approve pending subscriptions
 * will also be processed by this method.
 *
 * @param service the PubSub service this action is to be performed for.
 * @param message the Message packet sent to the pubsub service.
 */
public void process(PubSubService service, Message message) {
    if (message.getType() == Message.Type.error) {
        // Process Messages of type error to identify possible subscribers that no longer exist
        if (message.getError().getType() == PacketError.Type.cancel) {
            // TODO Assuming that owner is the bare JID (as defined in the JEP). This can be replaced with an explicit owner specified in the packet
            JID owner = message.getFrom().asBareJID();
            // Terminate the subscription of the entity to all nodes hosted at the service
           cancelAllSubscriptions(service, owner);
        }
        else if (message.getError().getType() == PacketError.Type.auth) {
            // TODO Queue the message to be sent again later (will retry a few times and
            // will be discarded when the retry limit is reached)
        }
    }
    else if (message.getType() == Message.Type.normal) {
        // Check that this is an answer to an authorization request
        DataForm authForm = (DataForm) message.getExtension("x", "jabber:x:data");
        if (authForm != null && authForm.getType() == DataForm.Type.submit) {
            String formType = authForm.getField("FORM_TYPE").getValues().get(0);
            // Check that completed data form belongs to an authorization request
            if ("http://jabber.org/protocol/pubsub#subscribe_authorization".equals(formType)) {
                // Process the answer to the authorization request
                processAuthorizationAnswer(service, authForm, message);
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:38,代码来源:PubSubEngine.java

示例3: handleDataFormElement

import org.xmpp.forms.DataForm; //导入方法依赖的package包/类
/**
 * Handles packets that includes a data form. The data form was sent using an element with name
 * "x" and namespace "jabber:x:data".
 *
 * @param senderRole  the role of the user that sent the data form.
 * @param formElement the element that contains the data form specification.
 * @throws ForbiddenException    if the user does not have enough privileges.
 * @throws ConflictException If the room was going to lose all of its owners.
 */
private void handleDataFormElement(MUCRole senderRole, Element formElement)
        throws ForbiddenException, ConflictException {
    DataForm completedForm = new DataForm(formElement);

    switch(completedForm.getType()) {
    case cancel:
        // If the room was just created (i.e. is locked) and the owner cancels the configuration
        // form then destroy the room
        if (room.isLocked()) {
            room.destroyRoom(null, null);
        }
        break;
        
    case submit:
        // The owner is requesting an instant room
        if (completedForm.getFields().isEmpty()) {
            // Do nothing
        }
        // The owner is requesting a reserved room or is changing the current configuration
        else {
            processConfigurationForm(completedForm, senderRole);
        }
        // If the room was locked, unlock it and send to the owner the "room is now unlocked"
        // message
        if (room.isLocked() && !room.isManuallyLocked()) {
            room.unlock(senderRole);
        }
        if (!room.isDestroyed) {
            // Let other cluster nodes that the room has been updated
            CacheFactory.doClusterTask(new RoomUpdatedEvent(room));
        }
        break;
        
    default:
    	Log.warn("cannot handle data form element: " + formElement.asXML());
    	break;
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:48,代码来源:IQOwnerHandler.java

示例4: process

import org.xmpp.forms.DataForm; //导入方法依赖的package包/类
/**
 * Handles Message packets sent to the pubsub service. Messages may be of type error
 * when an event notification was sent to a susbcriber whose address is no longer available.<p>
 *
 * Answers to authorization requests sent to node owners to approve pending subscriptions
 * will also be processed by this method.
 *
 * @param service the PubSub service this action is to be performed for.
 * @param message the Message packet sent to the pubsub service.
 */
public void process(PubSubService service, Message message) {
    if (message.getType() == Message.Type.error) {
        // Process Messages of type error to identify possible subscribers that no longer exist
        if (message.getError().getType() == PacketError.Type.cancel) {
            // TODO Assuming that owner is the bare JID (as defined in the JEP). This can be replaced with an explicit owner specified in the packet
            JID owner = new JID(message.getFrom().toBareJID());
            // Terminate the subscription of the entity to all nodes hosted at the service
           cancelAllSubscriptions(service, owner);
        }
        else if (message.getError().getType() == PacketError.Type.auth) {
            // TODO Queue the message to be sent again later (will retry a few times and
            // will be discarded when the retry limit is reached)
        }
    }
    else if (message.getType() == Message.Type.normal) {
        // Check that this is an answer to an authorization request
        DataForm authForm = (DataForm) message.getExtension("x", "jabber:x:data");
        if (authForm != null && authForm.getType() == DataForm.Type.submit) {
            String formType = authForm.getField("FORM_TYPE").getValues().get(0);
            // Check that completed data form belongs to an authorization request
            if ("http://jabber.org/protocol/pubsub#subscribe_authorization".equals(formType)) {
                // Process the answer to the authorization request
                processAuthorizationAnswer(service, authForm, message);
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:38,代码来源:PubSubEngine.java


注:本文中的org.xmpp.forms.DataForm.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。