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


Java ServerChannel类代码示例

本文整理汇总了Java中org.dna.mqtt.moquette.server.ServerChannel的典型用法代码示例。如果您正苦于以下问题:Java ServerChannel类的具体用法?Java ServerChannel怎么用?Java ServerChannel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerChannel类属于org.dna.mqtt.moquette.server包,在下文中一共展示了ServerChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processDisconnect

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
void processDisconnect(ServerChannel session, String clientID, boolean cleanSession) throws InterruptedException {

        String username = authSubjects.get(clientID).getUsername();
        removeAuthorizationSubject(clientID);

        if (cleanSession) {
            //cleanup topic subscriptions
            processRemoveAllSubscriptions(clientID);
        }
//        m_notifier.disconnect(evt.getSession());
        m_clientIDs.remove(clientID);
        session.close(true);

        //de-activate the subscriptions for this ClientID
        subscriptions.deactivate(clientID);

        try {
            AndesMQTTBridge.getBridgeInstance().onClientDisconnection(clientID, null,
                    username, AndesMQTTBridge.SubscriptionEvent.DISCONNECT);
            log.info("Disconnected client " + clientID + " with clean session " + cleanSession);
        } catch (MQTTException e) {
            log.error("Error occurred when attempting to disconnect subscriber", e);
        }
    }
 
开发者ID:wso2,项目名称:andes,代码行数:25,代码来源:ProtocolProcessor.java

示例2: processUnsubscribe

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
/**
 * Remove the clientID from topic subscription, if not previously subscribed,
 * doesn't reply any error
 */
void processUnsubscribe(ServerChannel session, String clientID, List<String> topics, int messageID) {
    if (log.isDebugEnabled()) {
        log.debug("processUnsubscribe invoked, removing subscription on topics " + topics + ", for clientID " + clientID);
    }

    for (String topic : topics) {
        subscriptions.removeSubscription(topic, clientID);
        //also will unsubscribe from the kernel
        try {
            AndesMQTTBridge.getBridgeInstance().onClientDisconnection(clientID, topic,
                    authSubjects.get(clientID).getUsername(),
                    AndesMQTTBridge.SubscriptionEvent.UNSUBSCRIBE);
        } catch (Exception e) {
            final String message = "Error occurred when disconnecting the subscriber ";
            log.error(message + e.getMessage());
        }
        // bridge.onClientDisconnection(clientID);
    }
    //ack the client
    UnsubAckMessage ackMessage = new UnsubAckMessage();
    ackMessage.setMessageID(messageID);

    log.info("replying with UnsubAck to MSG ID " + messageID);
    session.write(ackMessage);
}
 
开发者ID:wso2,项目名称:andes,代码行数:30,代码来源:ProtocolProcessor.java

示例3: processDisconnect

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
void processDisconnect(ServerChannel session, String clientID, boolean cleanSession) throws InterruptedException {
        if (cleanSession) {
            //cleanup topic subscriptions
            processRemoveAllSubscriptions(clientID);
        }
//        m_notifier.disconnect(evt.getSession());
        m_clientIDs.remove(clientID);
        session.close(true);

        //de-activate the subscriptions for this ClientID
        subscriptions.deactivate(clientID);
        //cleanup the will store
        m_willStore.remove(clientID);

        Log.info("Disconnected client <{}> with clean session {}", clientID, cleanSession);
    }
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:17,代码来源:ProtocolProcessor.java

示例4: processSubscribe

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
void processSubscribe(ServerChannel session, SubscribeMessage msg, String clientID, boolean cleanSession) {
    LOG.info(String.format("processSubscribe invoked from client %s with msgID %d", clientID, msg.getMessageID()));

    for (SubscribeMessage.Couple req : msg.subscriptions()) {
        AbstractMessage.QOSType qos = AbstractMessage.QOSType.values()[req.getQos()];
        Subscription newSubscription = new Subscription(clientID, req.getTopic(), qos, cleanSession);
        subscribeSingleTopic(newSubscription, req.getTopic());
    }

    //ack the client
    SubAckMessage ackMessage = new SubAckMessage();
    ackMessage.setMessageID(msg.getMessageID());

    //TODO by now it handles only QoS 0 messages
    for (int i = 0; i < msg.subscriptions().size(); i++) {
        ackMessage.addType(AbstractMessage.QOSType.MOST_ONE);
    }
    LOG.info("replying with SubAck to MSG ID " + msg.getMessageID());
    session.write(ackMessage);
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:21,代码来源:ProtocolProcessor.java

示例5: failedCredentials

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
/**
 * Added as an upgrade for 3.1.1 specification, This is adopted by WSO2 from Moquette
 *
 * @param session the server session which holds channel information
 */
private void failedCredentials(ServerChannel session) {
    ConnAckMessage okResp = new ConnAckMessage();
    okResp.setReturnCode(ConnAckMessage.BAD_USERNAME_OR_PASSWORD);
    session.write(okResp);
    session.close(false);
}
 
开发者ID:wso2,项目名称:andes,代码行数:12,代码来源:ProtocolProcessor.java

示例6: proccessConnectionLost

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
void proccessConnectionLost(String clientID) {

        boolean forciblyClosed = false;

        if (forciblyClosedChannels.containsKey(clientID)) {
            ServerChannel oldSession = forciblyClosedChannels.remove(clientID);
            ServerChannel newSession = m_clientIDs.get(clientID).getSession();

            // If the new channel and the old channel are not equal, this is a connection lost received from a
            // forcibly closed a connection. Hence remove the record and avoid processing connection lost for the old
            // session since it's session data has already been cleared
            if (null != newSession && !oldSession.getUUID().equals(newSession.getUUID())) {
                forciblyClosed = true;
            }
        }

        //If already removed a disconnect message was already processed for this clientID
        if (!forciblyClosed && m_clientIDs.remove(clientID) != null) {
            //de-activate the subscriptions for this ClientID
            subscriptions.deactivate(clientID);
            log.info("Lost connection with client " + clientID);
            //Andes change
            //Need to handle disconnection
            try {

            // We need to disconnect subscription only if client id exists in authSubjects.
            // If it's not existing in authSubjects Subscription has already removed or
            // subscription has never created due to invalid credentials.
            if(authSubjects.containsKey(clientID)) {
                String username = authSubjects.get(clientID).getUsername();
                AndesMQTTBridge.getBridgeInstance().onClientDisconnection(clientID, null, username,
                        AndesMQTTBridge.SubscriptionEvent.DISCONNECT);
            }
            } catch (MQTTException e) {
                final String message = "Error occurred when attempting to disconnect subscriber ";
                log.error(message + e.getMessage(), e);
            }
            removeAuthorizationSubject(clientID);
        }
    }
 
开发者ID:wso2,项目名称:andes,代码行数:41,代码来源:ProtocolProcessor.java

示例7: PublishEvent

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
public PublishEvent(PublishMessage pubMsg, String clientID, ServerChannel session) {
    m_topic = pubMsg.getTopicName();
    m_qos = pubMsg.getQos();
    m_message = pubMsg.getPayload();
    m_retain = pubMsg.isRetainFlag();
    m_clientID = clientID;
    m_session = session;
    if (pubMsg.getQos() != QOSType.MOST_ONE) {
        m_msgID = pubMsg.getMessageID();
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:12,代码来源:PublishEvent.java

示例8: processUnsubscribe

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
/**
 * Remove the clientID from topic subscription, if not previously subscribed,
 * doesn't reply any error
 */
void processUnsubscribe(ServerChannel session, String clientID, List<String> topics, int messageID) {
    Log.trace("processUnsubscribe invoked, removing subscription on topics {}, for clientID <{}>", topics, clientID);

    for (String topic : topics) {
        subscriptions.removeSubscription(topic, clientID);
    }
    //ack the client
    UnsubAckMessage ackMessage = new UnsubAckMessage();
    ackMessage.setMessageID(messageID);

    Log.trace("replying with UnsubAck to MSG ID {}", messageID);
    session.write(ackMessage);
}
 
开发者ID:kevoree,项目名称:kevoree-library,代码行数:18,代码来源:ProtocolProcessor.java

示例9: processDisconnect

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
void processDisconnect(ServerChannel session, String clientID, boolean cleanSession) throws InterruptedException {
        if (cleanSession) {
            //cleanup topic subscriptions
            processRemoveAllSubscriptions(clientID);
        }
//        m_notifier.disconnect(evt.getSession());
        m_clientIDs.remove(clientID);
        session.close(true);

        //de-activate the subscriptions for this ClientID
//        String clientID = (String) evt.getSession().getAttribute(Constants.ATTR_CLIENTID);
        subscriptions.deactivate(clientID);
    }
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:14,代码来源:ProtocolProcessor.java

示例10: processUnsubscribe

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
/**
 * Remove the clientID from topic subscription, if not previously subscribed,
 * doesn't reply any error
 */
void processUnsubscribe(ServerChannel session, String clientID, List<String> topics, int messageID) {
    LOG.debug("processSubscribe invoked");

    for (String topic : topics) {
        subscriptions.removeSubscription(topic, clientID);
    }
    //ack the client
    UnsubAckMessage ackMessage = new UnsubAckMessage();
    ackMessage.setMessageID(messageID);

    LOG.info(String.format("replying with UnsubAck to MSG ID %s", messageID));
    session.write(ackMessage);
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:18,代码来源:ProtocolProcessor.java

示例11: PublishEvent

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
public PublishEvent(String topic, QOSType qos, byte[] message, boolean retain,
        String clientID, ServerChannel session) {
    m_topic = topic;
    m_qos = qos;
    m_message = message;
    m_retain = retain;
    m_clientID = clientID;
    m_session = session;
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:10,代码来源:PublishEvent.java

示例12: getSession

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
public ServerChannel getSession() {
    return m_session;
}
 
开发者ID:wso2,项目名称:andes,代码行数:4,代码来源:PublishEvent.java

示例13: OutputMessagingEvent

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
public OutputMessagingEvent(ServerChannel channel, AbstractMessage message) {
    m_channel = channel;
    m_message = message;
}
 
开发者ID:wso2,项目名称:andes,代码行数:5,代码来源:OutputMessagingEvent.java

示例14: getChannel

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
public ServerChannel getChannel() {
    return m_channel;
}
 
开发者ID:wso2,项目名称:andes,代码行数:4,代码来源:OutputMessagingEvent.java

示例15: DisconnectEvent

import org.dna.mqtt.moquette.server.ServerChannel; //导入依赖的package包/类
public DisconnectEvent(ServerChannel session) {
    m_session = session;
}
 
开发者ID:wso2,项目名称:andes,代码行数:4,代码来源:DisconnectEvent.java


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