-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
websocket: updates the websocket server to be able to use another server socket #20103
Merged
Conversation
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
spytheman
reviewed
Dec 6, 2023
spytheman
reviewed
Dec 6, 2023
spytheman
reviewed
Dec 6, 2023
I think this draft PR is good to be merged, does it need something else @el-gringo ? |
shove70
reviewed
Dec 8, 2023
…er server to handle handshake resquests - adds `is_headless` attribute to `webscokect.Server` - adds public function to handle handcheck from a `TcpConn` for a given key - adds a `vweb` example - adds `Sec-WebSocket-Key` as common HTTP header
spytheman
force-pushed
the
feat/websocket_headless
branch
from
December 18, 2023 13:41
2a0474e
to
9e374a0
Compare
(rebased over current master) |
spytheman
changed the title
websocket: updates the websocket server to use an other server socket
websocket: updates the websocket server to be able to use another server socket
Dec 19, 2023
spytheman
approved these changes
Dec 19, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, I am very new to vlang, so I might have done things wrong.
I updated the
websocket.Server
to allow it to not start a listener socket in order to use an external one (ie: vweb).There are some caveats :
.js
file. This is a small script and could be inlined in a<script type="text/javascript">
inindex.html
but the compiler try to parse it and fail.🤖[deprecated] Generated by Copilot at 8174157
This pull request adds an example of using the
net.websocket
module to create a headless WebSocket server and a vweb application that serves a simple WebSocket client. It also adds support for theSec-WebSocket-Key
header in thenet.http
module, which is needed for WebSocket handshaking. The example demonstrates how to handle WebSocket events, send and receive messages, and update the HTML page using JavaScript.🤖[deprecated] Generated by Copilot at 8174157
vweb_websocket.v
file that creates anet.websocket.Server
instance and registers callbacks for WebSocket events (link)handle_handshake
method of the WebSocket server (link, link)Sec-WebSocket-Key
header in thenet.http.Header
enum and its methods (link, link, link)is_headless
to thenet.websocket.Server
struct to indicate whether the server should start its own listener or use an external server (link)accept_client
method of thenet.websocket.Server
struct to extract the logic for attaching a client and sending the handshake response to a new methodattach_client
(link)index.html
file that loads thewebsocket_client.js
script and displays an ordered list of messages exchanged with the server (link)websocket_client.js
file that implements a simple WebSocket client that connects to the server, sends and receives messages, and updates the HTML page with the message list (link)