-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MoP accept ws proxy connections (#1586)
- Loading branch information
Showing
9 changed files
with
176 additions
and
40 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
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
48 changes: 48 additions & 0 deletions
48
...ommon/src/main/java/io/streamnative/pulsar/handlers/mqtt/common/utils/WebSocketUtils.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,48 @@ | ||
/** | ||
* Licensed 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 io.streamnative.pulsar.handlers.mqtt.common.utils; | ||
|
||
import io.netty.channel.ChannelPipeline; | ||
import io.netty.handler.codec.http.HttpContentCompressor; | ||
import io.netty.handler.codec.http.HttpObjectAggregator; | ||
import io.netty.handler.codec.http.HttpServerCodec; | ||
import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; | ||
import io.streamnative.pulsar.handlers.mqtt.common.Constants; | ||
import io.streamnative.pulsar.handlers.mqtt.common.MQTTCommonConfiguration; | ||
import io.streamnative.pulsar.handlers.mqtt.common.codec.MqttWebSocketCodec; | ||
|
||
public class WebSocketUtils { | ||
|
||
/** | ||
* Add websocket handler. | ||
* | ||
* @param pipeline | ||
*/ | ||
public static void addWsHandler(ChannelPipeline pipeline, MQTTCommonConfiguration configuration) { | ||
// Encode or decode request and reply messages into HTTP messages | ||
pipeline.addLast(Constants.HANDLER_HTTP_CODEC, new HttpServerCodec()); | ||
|
||
// Combine the parts of an HTTP message into a complete HTTP message | ||
pipeline.addLast(Constants.HANDLER_HTTP_AGGREGATOR, | ||
new HttpObjectAggregator(configuration.getHttpMaxContentLength())); | ||
|
||
// Compress and encode HTTP messages | ||
pipeline.addLast(Constants.HANDLER_HTTP_COMPRESSOR, new HttpContentCompressor()); | ||
|
||
pipeline.addLast(Constants.HANDLER_WEB_SOCKET_SERVER_PROTOCOL, | ||
new WebSocketServerProtocolHandler(configuration.getWebSocketPath(), | ||
Constants.MQTT_SUB_PROTOCOL_CSV_LIST, true, configuration.getWebSocketMaxFrameSize())); | ||
pipeline.addLast(Constants.HANDLER_MQTT_WEB_SOCKET_CODEC, new MqttWebSocketCodec()); | ||
} | ||
} |
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