-
Notifications
You must be signed in to change notification settings - Fork 198
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 support #395
Open
SquidDev
wants to merge
4
commits into
dan200:master
Choose a base branch
from
SquidDev-CC:feature/websocket
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Websocket support #395
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
The API description which you gave at the start of your post sounds like it mimics the rednet/modem API's in interface, which I would consider a plus as that is what some users of the mod will be more familiar with when using the API. |
SquidDev
force-pushed
the
feature/websocket
branch
from
September 10, 2017 08:32
3ce0d09
to
89578b4
Compare
This means we don't have to have lots of shared state between the run and whenFinished method, and allows for easier chaining of futures later on.
SquidDev
force-pushed
the
feature/websocket
branch
from
September 11, 2017 21:16
89578b4
to
fe787be
Compare
I made what I believe to be the first public software to use this PR. It makes a file handle interface to the WebsocketConnection object. |
SquidDev
force-pushed
the
feature/websocket
branch
from
November 15, 2017 11:32
fe787be
to
30f4e08
Compare
This uses Netty's websocket functionality, meaning we do not have to depend on another library. As websockets do not fit neatly into the standard polling socket model, the API is significantly more event based than CCTweaks's. One uses http.websocket to connect, which will wait until a connection is established and then returns the connection object (an async variant is available). Once you have a websocket object, you can use .send(msg) to transmit a message. Incoming messages will fire a "websocket_message" event, with the URL and content as arguments. A convenience method (.receive()) exists to aid waiting for valid messages.
SquidDev
force-pushed
the
feature/websocket
branch
from
December 6, 2017 09:34
30f4e08
to
2bb5ce5
Compare
Closed
- Add an argument to send which controls whether it's a binary message or not. This is a little ugly, but it's probably more effective than anything else. - Fix binary frames not correctly queueing the correct data in the message event.
ccserver
pushed a commit
to ccserver/ComputerCraft
that referenced
this pull request
Sep 16, 2019
…websocket Websocket support
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.
This uses Netty's websocket functionality, meaning we do not have to depend on another library.
API
As websockets do not fit neatly into the standard polling socket model, the API is significantly more event based than CCTweaks's. One uses
http.websocket
to connect, which will wait until a connection is established and then returns the connection object (an async variant is available).Once you have a websocket object, you can use
.send(msg)
to transmit a message. Incoming messages will fire a "websocket_message" event, with the URL and content as arguments. A convenience method (.receive()
) exists to aid waiting for valid messages.A
websocket_closed
event is also fired if the server forcibly terminates the connection, or it times out.I'd really appreciate feedback on this - I'm not entirely sure it's the best approach, but IMO it's neater than CCTweaks's.
Example
Possible enhancements
These are things which probably should be implemented at some point, but I'm looking for some thoughts on them first. Not all of them are entirely websocket related.
ILuaObject
part and the socket holding part, detecting when the former is no longer referenced.receive()
. I'm not sure the best way to go about that - we obviously don't have access toos.startTimer
on the Java side.Closes #161