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

Feat: WebSocket Client #369

Draft
wants to merge 34 commits into
base: release52
Choose a base branch
from
Draft

Conversation

olzzon
Copy link
Contributor

@olzzon olzzon commented Feb 26, 2025

About the Contributor

This is made on behalf of BBC

Type of Contribution

This is a feature and code comment improvements

Current Behavior

New Behavior

This adds support for a general WS socket device

Testing Instructions

Other Information

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@olzzon olzzon requested a review from a team as a code owner February 26, 2025 09:48
@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 46.66667% with 56 lines in your changes missing coverage. Please review.

Project coverage is 57.12%. Comparing base (9917b7f) to head (40dfc34).

Files with missing lines Patch % Lines
...ver/src/integrations/websocketClient/connection.ts 6.97% 36 Missing and 4 partials ⚠️
...resolver/src/integrations/websocketClient/index.ts 70.21% 13 Missing and 1 partial ⚠️
...ges/timeline-state-resolver/src/service/devices.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           release52     #369      +/-   ##
=============================================
- Coverage      57.22%   57.12%   -0.10%     
=============================================
  Files            160      164       +4     
  Lines          11016    11121     +105     
  Branches        2686     2707      +21     
=============================================
+ Hits            6304     6353      +49     
- Misses          4323     4374      +51     
- Partials         389      394       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mint-dewit mint-dewit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it seems this PR hasn't been linted and formatted. It is recommended to have automatic formatting on save enabled in the Sofie projects, and commit hooks to fail when the linting doesn't pass on commit.

I am quite confused as to why an additional device integration is being added for TCP connections when we already have the TCPSendDevice. There appears to be no benefit to having the TCP connection be an option in this integration.

[WebsocketTcpClientActions.ResetState]: async (_id: string) => {
return { result: ActionExecutionResultCode.Ok }
},
[WebsocketTcpClientActions.SendWebSocketMessage]: async (_id: string, payload?: Record<string, any>) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typings for the payload are wrong, as per the actions.json it should be

Suggested change
[WebsocketTcpClientActions.SendWebSocketMessage]: async (_id: string, payload?: Record<string, any>) => {
[WebsocketTcpClientActions.SendWebSocketMessage]: async (_id: string, payload?: SendWebSocketMessagePayload) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I've misunderstood something, but from looking through the code in the other integrations, it does look like the actions payload need to be a Record<string, xxx> type

So I changed the type from any it to:
payload?: Record<string, SendWebSocketMessagePayload>

And the iterate over the Record and send the message directly to the connection.

afterEach(() => {
//Are there something like??:
//mockTime.dispose()
// Or can we just ignore this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to clear the mocks here and reset the timeMock

})

test('terminate', async () => {
await device.terminate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could cause race conditions when this test is ran in parallel with other tests

@olzzon olzzon marked this pull request as draft February 26, 2025 14:09
@olzzon olzzon changed the title Feat: WebSocket + TCP Client Feat: WebSocket Client Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants