-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.remove Session and SessionManagerImpl 2.handle NPE when decode/enco…
…de between MqttMessage and RemotingCommand 3.add topic<--->subscription data 4.add subscribe and suback logic
- Loading branch information
chengxiangwang
committed
Feb 16, 2019
1 parent
837e7e9
commit c722a44
Showing
23 changed files
with
472 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MqttSubscriptionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $ | ||
*/ | ||
package org.apache.rocketmq.common.protocol.heartbeat; | ||
|
||
public class MqttSubscriptionData extends SubscriptionData { | ||
private int qos; | ||
private String clientId; | ||
|
||
public MqttSubscriptionData() { | ||
|
||
} | ||
|
||
public MqttSubscriptionData(int qos, String clientId, String topicFilter) { | ||
super(topicFilter,null); | ||
this.qos = qos; | ||
this.clientId = clientId; | ||
} | ||
|
||
public int getQos() { | ||
return qos; | ||
} | ||
|
||
public void setQos(int qos) { | ||
this.qos = qos; | ||
} | ||
|
||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
public void setClientId(String clientId) { | ||
this.clientId = clientId; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((this.getTopic() == null) ? 0 : this.getTopic().hashCode()); | ||
result = prime * result + ((clientId == null) ? 0 : clientId.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
MqttSubscriptionData other = (MqttSubscriptionData) obj; | ||
if (qos != other.qos) | ||
return false; | ||
if (clientId != other.clientId) { | ||
return false; | ||
} | ||
if (this.getTopic() != other.getTopic()) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override public String toString() { | ||
return "MqttSubscriptionData{" + | ||
"qos=" + qos + | ||
", topic='" + this.getTopic() + '\'' + | ||
", clientId='" + clientId + '\'' + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
.../src/main/java/org/apache/rocketmq/remoting/transport/mqtt/RocketMQMqttSubAckPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.rocketmq.remoting.transport.mqtt; | ||
|
||
import io.netty.handler.codec.mqtt.MqttSubAckMessage; | ||
import io.netty.handler.codec.mqtt.MqttSubAckPayload; | ||
import io.netty.util.internal.StringUtil; | ||
import java.io.UnsupportedEncodingException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.apache.rocketmq.remoting.serialize.RemotingSerializable; | ||
|
||
/** | ||
* Payload of {@link MqttSubAckMessage} | ||
*/ | ||
public final class RocketMQMqttSubAckPayload extends RemotingSerializable { | ||
|
||
private List<Integer> grantedQoSLevels; | ||
|
||
public RocketMQMqttSubAckPayload(List<Integer> grantedQoSLevels) { | ||
this.grantedQoSLevels = Collections.unmodifiableList(grantedQoSLevels); | ||
} | ||
|
||
public List<Integer> getGrantedQoSLevels() { | ||
return grantedQoSLevels; | ||
} | ||
|
||
public void setGrantedQoSLevels(List<Integer> grantedQoSLevels) { | ||
this.grantedQoSLevels = grantedQoSLevels; | ||
} | ||
|
||
public static RocketMQMqttSubAckPayload fromMqttSubAckPayload(MqttSubAckPayload payload) { | ||
return new RocketMQMqttSubAckPayload(payload.grantedQoSLevels()); | ||
} | ||
|
||
public MqttSubAckPayload toMqttSubAckPayload() throws UnsupportedEncodingException { | ||
return new MqttSubAckPayload(this.grantedQoSLevels); | ||
} | ||
@Override | ||
public String toString() { | ||
return StringUtil.simpleClassName(this) + '[' + "grantedQoSLevels=" + this.grantedQoSLevels + ']'; | ||
} | ||
} |
Oops, something went wrong.