Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Close Frame Record return type support #1497

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4a4316a
Add initial implementation
chathushkaayash Feb 11, 2025
96a2078
Merge pull request #1 from ballerina-platform/main
chathushkaayash Feb 11, 2025
42a174b
[Automated] Update the native jar versions
chathushkaayash Feb 11, 2025
cd92e80
Update licenses and remove parenthesis in if statements
chathushkaayash Feb 11, 2025
02ff641
Sync the fork (#2)
chathushkaayash Feb 13, 2025
df2600b
Merge pull request #3 from ballerina-platform/main
chathushkaayash Feb 13, 2025
0027a06
Update close frame records based on new suggestions
chathushkaayash Feb 17, 2025
34f51f6
Fix type casting for close frame reason in WebSocketResourceDispatcher
chathushkaayash Feb 17, 2025
40eb6ea
Add `ProtocolError` close frame record and related tests
chathushkaayash Feb 18, 2025
dc7e975
[Automated] Update the native jar versions
chathushkaayash Feb 18, 2025
1db08cb
Add close frame support tests for custom dispatcher methods
chathushkaayash Feb 18, 2025
401866b
Merge pull request #4 from ballerina-platform/main
chathushkaayash Feb 19, 2025
a3b48fe
Update changelog and spec
chathushkaayash Feb 19, 2025
f8f177e
Update changelog and spec addressing minor issues
chathushkaayash Feb 20, 2025
24aa6f7
Merge pull request #5 from ballerina-platform/main
chathushkaayash Feb 20, 2025
e66a237
Add getErrorMessage function for getting error messages from predefin…
chathushkaayash Feb 20, 2025
6d0b62c
Update isCloseFrameRecord logic
chathushkaayash Feb 20, 2025
fb843cb
Fix isCloseFrameRecord checking logic
chathushkaayash Feb 21, 2025
19870f5
Merge pull request #6 from ballerina-platform/main
chathushkaayash Feb 21, 2025
0e88592
Update close frame type checking to use TypeUtils
chathushkaayash Feb 21, 2025
d7ec049
Merge branch 'main' of https://github.com/chathushkaayash/module-ball…
chathushkaayash Feb 21, 2025
b691626
Merge pull request #7 from ballerina-platform/main
chathushkaayash Feb 24, 2025
20eb8c2
Merge branch 'main' into main
chathushkaayash Mar 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "websocket"
version = "2.13.1"
version = "2.13.2"
authors = ["Ballerina"]
keywords = ["ws", "network", "bi-directional", "streaming", "service", "client"]
repository = "https://github.com/ballerina-platform/module-ballerina-websocket"
Expand All @@ -15,8 +15,8 @@ graalvmCompatible = true
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "websocket-native"
version = "2.13.1"
path = "../native/build/libs/websocket-native-2.13.1.jar"
version = "2.13.2"
path = "../native/build/libs/websocket-native-2.13.2-SNAPSHOT.jar"

[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
Expand Down Expand Up @@ -85,5 +85,5 @@ version = "4.1.118.Final"
path = "./lib/netty-handler-proxy-4.1.118.Final.jar"

[[platform.java21.dependency]]
path = "../test-utils/build/libs/websocket-test-utils-2.13.1.jar"
path = "../test-utils/build/libs/websocket-test-utils-2.13.2-SNAPSHOT.jar"
scope = "testOnly"
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "websocket-compiler-plugin"
class = "io.ballerina.stdlib.websocket.plugin.WebSocketCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/websocket-compiler-plugin-2.13.1.jar"
path = "../compiler-plugin/build/libs/websocket-compiler-plugin-2.13.2-SNAPSHOT.jar"
4 changes: 2 additions & 2 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.13.1"
version = "2.13.2"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down Expand Up @@ -342,7 +342,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "websocket"
version = "2.13.1"
version = "2.13.2"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "constraint"},
Expand Down
101 changes: 101 additions & 0 deletions ballerina/close_frame_return_types.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Copyright (c) 2025, WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. 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.

public readonly distinct class PredefinedCloseFrameType {
};

public readonly distinct class CustomCloseFrameType {
};

public final PredefinedCloseFrameType PREDEFINED_CLOSE_FRAME = new;
public final CustomCloseFrameType CUSTOM_CLOSE_FRAME = new;

type CloseFrameBase record {|
readonly object {} 'type;
readonly int status;
string reason?;
|};

public type CustomCloseFrame record {|
*CloseFrameBase;
readonly CustomCloseFrameType 'type = CUSTOM_CLOSE_FRAME;
|};

public type NormalClosure record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1000 status = 1000;
|};

public type GoingAway record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1001 status = 1001;
|};

public type ProtocolError record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1002 status = 1002;
string reason = "Connection closed due to protocol error";
|};

public type UnsupportedData record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1003 status = 1003;
string reason = "Endpoint received unsupported frame";
|};

public type InvalidPayload record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1007 status = 1007;
string reason = "Payload does not match the expected format or encoding";
|};

public type PolicyViolation record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1008 status = 1008;
string reason = "Received message violates its policy";
|};

public type MessageTooBig record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1009 status = 1009;
string reason = "The received message exceeds the allowed size limit";
|};

public type InternalServerError record {|
*CloseFrameBase;
readonly PredefinedCloseFrameType 'type = PREDEFINED_CLOSE_FRAME;
readonly 1011 status = 1011;
string reason = "Internal server error occurred";
|};

public final readonly & NormalClosure NORMAL_CLOSURE = {};
public final readonly & GoingAway GOING_AWAY = {};
public final readonly & ProtocolError PROTOCOL_ERROR = {};
public final readonly & UnsupportedData UNSUPPORTED_DATA = {};
public final readonly & InvalidPayload INVALID_PAYLOAD = {};
public final readonly & PolicyViolation POLICY_VIOLATION = {};
public final readonly & MessageTooBig MESSAGE_TOO_BIG = {};
public final readonly & InternalServerError INTERNAL_SERVER_ERROR = {};

public type CloseFrame NormalClosure|GoingAway|ProtocolError|UnsupportedData|InvalidPayload|
PolicyViolation|MessageTooBig|InternalServerError|CustomCloseFrame;
Loading