congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
SubscribeStore
Code IndexAdd Tabnine to your IDE (free)

How to use
SubscribeStore
in
cn.wizzer.iot.mqtt.server.common.subscribe

Best Java code snippets using cn.wizzer.iot.mqtt.server.common.subscribe.SubscribeStore (Showing top 4 results out of 315)

origin: Wizzercn/MqttWk

private void sendPublishMessage(String clientId, String topic, MqttQoS mqttQoS, byte[] messageBytes, boolean retain, boolean dup) {
  List<SubscribeStore> subscribeStores = subscribeStoreService.search(topic);
  subscribeStores.forEach(subscribeStore -> {
    if (!clientId.equals(subscribeStore.getClientId()) && sessionStoreService.containsKey(subscribeStore.getClientId())) {
      MqttQoS respQoS = mqttQoS.value() > subscribeStore.getMqttQoS() ? MqttQoS.valueOf(subscribeStore.getMqttQoS()) : mqttQoS;
      if (respQoS == MqttQoS.AT_MOST_ONCE) {
        MqttPublishMessage publishMessage = (MqttPublishMessage) MqttMessageFactory.newMessage(
            new MqttFixedHeader(MqttMessageType.PUBLISH, dup, respQoS, retain, 0),
            new MqttPublishVariableHeader(topic, 0), ByteBuffer.wrap(messageBytes));
        LOGGER.debug("PUBLISH - clientId: {}, topic: {}, Qos: {}", subscribeStore.getClientId(), topic, respQoS.value());
        ChannelId channelId = channelIdMap.get(sessionStoreService.get(subscribeStore.getClientId()).getChannelId());
        if (channelId != null) {
          Channel channel = channelGroup.find(channelId);
            new MqttFixedHeader(MqttMessageType.PUBLISH, dup, respQoS, retain, 0),
            new MqttPublishVariableHeader(topic, messageId), ByteBuffer.wrap(messageBytes));
        LOGGER.debug("PUBLISH - clientId: {}, topic: {}, Qos: {}, messageId: {}", subscribeStore.getClientId(), topic, respQoS.value(), messageId);
        ChannelId channelId = channelIdMap.get(sessionStoreService.get(subscribeStore.getClientId()).getChannelId());
        if (channelId != null) {
          Channel channel = channelGroup.find(channelId);
            new MqttFixedHeader(MqttMessageType.PUBLISH, dup, respQoS, retain, 0),
            new MqttPublishVariableHeader(topic, messageId), ByteBuffer.wrap(messageBytes));
        LOGGER.debug("PUBLISH - clientId: {}, topic: {}, Qos: {}, messageId: {}", subscribeStore.getClientId(), topic, respQoS.value(), messageId);
        ChannelId channelId = channelIdMap.get(sessionStoreService.get(subscribeStore.getClientId()).getChannelId());
        if (channelId != null) {
          Channel channel = channelGroup.find(channelId);
origin: Wizzercn/MqttWk

@Override
public void put(String topicFilter, SubscribeStore subscribeStore) {
  if (StrUtil.contains(topicFilter, '#') || StrUtil.contains(topicFilter, '+')) {
    subscribeWildcardCache.put(topicFilter, subscribeStore.getClientId(), subscribeStore);
  } else {
    subscribeNotWildcardCache.put(topicFilter, subscribeStore.getClientId(), subscribeStore);
  }
}
origin: Wizzercn/MqttWk

public void processSubscribe(Channel channel, MqttSubscribeMessage msg) {
  List<MqttTopicSubscription> topicSubscriptions = msg.payload().topicSubscriptions();
  if (this.validTopicFilter(topicSubscriptions)) {
    String clientId = (String) channel.attr(AttributeKey.valueOf("clientId")).get();
    List<Integer> mqttQoSList = new ArrayList<Integer>();
    topicSubscriptions.forEach(topicSubscription -> {
      String topicFilter = topicSubscription.topicName();
      MqttQoS mqttQoS = topicSubscription.qualityOfService();
      SubscribeStore subscribeStore = new SubscribeStore(clientId, topicFilter, mqttQoS.value());
      subscribeStoreService.put(topicFilter, subscribeStore);
      mqttQoSList.add(mqttQoS.value());
      LOGGER.debug("SUBSCRIBE - clientId: {}, topFilter: {}, QoS: {}", clientId, topicFilter, mqttQoS.value());
    });
    MqttSubAckMessage subAckMessage = (MqttSubAckMessage) MqttMessageFactory.newMessage(
      new MqttFixedHeader(MqttMessageType.SUBACK, false, MqttQoS.AT_MOST_ONCE, false, 0),
      MqttMessageIdVariableHeader.from(msg.variableHeader().messageId()),
      new MqttSubAckPayload(mqttQoSList));
    channel.writeAndFlush(subAckMessage);
    // 发布保留消息
    topicSubscriptions.forEach(topicSubscription -> {
      String topicFilter = topicSubscription.topicName();
      MqttQoS mqttQoS = topicSubscription.qualityOfService();
      this.sendRetainMessage(channel, topicFilter, mqttQoS);
    });
  } else {
    channel.close();
  }
}
origin: Wizzercn/MqttWk

private void sendPublishMessage(String topic, MqttQoS mqttQoS, byte[] messageBytes, boolean retain, boolean dup) {
  List<SubscribeStore> subscribeStores = subscribeStoreService.search(topic);
  subscribeStores.forEach(subscribeStore -> {
    if (sessionStoreService.containsKey(subscribeStore.getClientId())) {
      MqttQoS respQoS = mqttQoS.value() > subscribeStore.getMqttQoS() ? MqttQoS.valueOf(subscribeStore.getMqttQoS()) : mqttQoS;
      if (respQoS == MqttQoS.AT_MOST_ONCE) {
        MqttPublishMessage publishMessage = (MqttPublishMessage) MqttMessageFactory.newMessage(
            new MqttFixedHeader(MqttMessageType.PUBLISH, dup, respQoS, retain, 0),
            new MqttPublishVariableHeader(topic, 0), Unpooled.buffer().writeBytes(messageBytes));
        LOGGER.debug("PUBLISH - clientId: {}, topic: {}, Qos: {}", subscribeStore.getClientId(), topic, respQoS.value());
        ChannelId channelId = channelIdMap.get(sessionStoreService.get(subscribeStore.getClientId()).getChannelId());
        if(channelId!=null) {
          Channel channel = channelGroup.find(channelId);
            new MqttFixedHeader(MqttMessageType.PUBLISH, dup, respQoS, retain, 0),
            new MqttPublishVariableHeader(topic, messageId), Unpooled.buffer().writeBytes(messageBytes));
        LOGGER.debug("PUBLISH - clientId: {}, topic: {}, Qos: {}, messageId: {}", subscribeStore.getClientId(), topic, respQoS.value(), messageId);
        DupPublishMessageStore dupPublishMessageStore = new DupPublishMessageStore().setClientId(subscribeStore.getClientId())
            .setTopic(topic).setMqttQoS(respQoS.value()).setMessageBytes(messageBytes).setMessageId(messageId);
        dupPublishMessageStoreService.put(subscribeStore.getClientId(), dupPublishMessageStore);
        ChannelId channelId = channelIdMap.get(sessionStoreService.get(subscribeStore.getClientId()).getChannelId());
        if(channelId!=null) {
          Channel channel = channelGroup.find(channelId);
            new MqttFixedHeader(MqttMessageType.PUBLISH, dup, respQoS, retain, 0),
            new MqttPublishVariableHeader(topic, messageId), Unpooled.buffer().writeBytes(messageBytes));
        LOGGER.debug("PUBLISH - clientId: {}, topic: {}, Qos: {}, messageId: {}", subscribeStore.getClientId(), topic, respQoS.value(), messageId);
        DupPublishMessageStore dupPublishMessageStore = new DupPublishMessageStore().setClientId(subscribeStore.getClientId())
            .setTopic(topic).setMqttQoS(respQoS.value()).setMessageBytes(messageBytes).setMessageId(messageId);
cn.wizzer.iot.mqtt.server.common.subscribeSubscribeStore

Javadoc

订阅存储

Most used methods

  • getClientId
  • <init>
  • getMqttQoS

Popular in Java

  • Start an intent from android
  • findViewById (Activity)
  • scheduleAtFixedRate (Timer)
  • getSystemService (Context)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Kernel (java.awt.image)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now