Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAMEL-12005: Add websocket support to camel-undertow
- Loading branch information
Showing
24 changed files
with
2,374 additions
and
193 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
79 changes: 79 additions & 0 deletions
79
...s/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConstants.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,79 @@ | |||
/** | |||
* 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.camel.component.undertow; | |||
|
|||
public final class UndertowConstants { | |||
|
|||
public static final String CONNECTION_KEY = "websocket.connectionKey"; | |||
public static final String CONNECTION_KEY_LIST = "websocket.connectionKey.list"; | |||
public static final String SEND_TO_ALL = "websocket.sendToAll"; | |||
public static final String EVENT_TYPE = "websocket.eventType"; | |||
public static final String EVENT_TYPE_ENUM = "websocket.eventTypeEnum"; | |||
|
|||
/** | |||
* WebSocket peers related events the {@link UndertowConsumer} sends to the Camel route. | |||
*/ | |||
public enum EventType { | |||
/** | |||
* A new peer has connected. | |||
*/ | |||
ONOPEN(1), | |||
|
|||
/** | |||
* A peer has disconnected. | |||
*/ | |||
ONCLOSE(0), | |||
|
|||
/** | |||
* Unused in Undertow component. Kept for compatibility with Camel websocket component. | |||
*/ | |||
ONERROR(-1); | |||
private final int code; | |||
|
|||
EventType(int code) { | |||
this.code = code; | |||
} | |||
|
|||
/** | |||
* @return a numeric identifier of this {@link EventType}. Kept for compatibility with Camel websocket | |||
* component. | |||
*/ | |||
public int getCode() { | |||
return code; | |||
} | |||
|
|||
public static EventType ofCode(int code) { | |||
switch (code) { | |||
case 1: | |||
return ONOPEN; | |||
case 0: | |||
return ONCLOSE; | |||
case -1: | |||
return ONERROR; | |||
default: | |||
throw new IllegalArgumentException("Cannot find an " + EventType.class.getName() + " for code " + code); | |||
} | |||
} | |||
} | |||
|
|||
public static final String WS_PROTOCOL = "ws"; | |||
public static final String WSS_PROTOCOL = "wss"; | |||
|
|||
private UndertowConstants() { | |||
}; | |||
|
|||
} |
Oops, something went wrong.