Skip to content

Websockets #1322

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

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

Websockets #1322

wants to merge 14 commits into from

Conversation

jbrichau
Copy link
Member

Added support for Websockets in Seaside.

@jbrichau jbrichau marked this pull request as draft August 16, 2022 14:22
@@ -0,0 +1,8 @@
printing
javascriptContentOn: aStream
"TODO: window.location should not be retrieved here..."
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use #baseUrl or something similar here instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. It should probably use the settings of WARequestHandlingConfiguration... it's just that I do not prefer that way of working. Alas, I see no alternative either.

@@ -0,0 +1,4 @@
protected
socketsDo: aOneArgumentBlock
self mutex critical: [
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a ^ be helpful here so the sender can easily access the return value from the provided block?

Transcript cr; show: 'New ', aWAWebSocket printString.

aWAWebSocket onMessage:[ :data |
self socketsDo: [ :socket | socket send: data ] ].
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit concerned about the socket iteration pattern.

  • In this case, and probably others, since #socketsDo: acquires a mutex it blocks until data has been sent to all sockets. I wonder if it would be beneficial to have some sort of job/task queue and submitting a task for every socket and hold the mutex only for submitting the tasks.
  • Between when we decided to send data to the sockets and actually doing it the socket may have become closed or invalid which makes we wonder whether we should:
    • check each web socket for validity in #send: and possibly removing it
    • wrap each #send: in an #on:do:
  • Having all the sockets in an array, linearly scanning over them and hoping #onClose: will always get sent and the web socket removed. I'm concerned with scalability and that we end up with dead or closed web sockets in the array that never get removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, all valid concerns and this still needs to be addressed. In addition, the seaside session needs to be kept alive as long as the sockets are communicating/existing. While doing experiments with the simple counter example, I encounter websocket connections being closed without any callback firing without a consistent timeout or other immediately visible reason. So, I still have a long way to go to make sure this works in practice.

@@ -1,6 +1,9 @@
converting
responseFrom: aRequestContext
| partialHeaders cookies fullHeaders seasideResponse contents entity contentType |
"TODO: is websocket only... useful/needed to package in separate package?"
(aRequestContext properties at: #webSocket ifAbsent:[ nil ])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do something special when shutting down the server?

Johan Brichau added 6 commits August 22, 2022 19:51
# Conflicts:
#	repository/BaselineOfSeaside3.package/BaselineOfSeaside3.class/instance/baselineadaptors..st
#	repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/websocketResponseFrom..st
Copy link

codecov bot commented Jul 14, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 49.41%. Comparing base (7058248) to head (0f5c233).

Files with missing lines Patch % Lines
...erAdaptor.class/instance/websocketResponseFrom..st 0.00% 9 Missing ⚠️
...ZnZincServerAdaptor.class/instance/statusString.st 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1322      +/-   ##
==========================================
- Coverage   49.41%   49.41%   -0.01%     
==========================================
  Files        9118     9119       +1     
  Lines       80389    80405      +16     
==========================================
+ Hits        39726    39729       +3     
- Misses      40663    40676      +13     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants