-
Notifications
You must be signed in to change notification settings - Fork 796
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
C++ API WebSocket example #624
Conversation
pos_ += 2; | ||
for (int i = 0; i < 2; ++i, ++pos_) { | ||
msg_len <<= 8; | ||
msg_len += (unsigned char)(ws_buf_[pos_]); |
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.
You're neglecting network byte order to host order conversions, you need to use nthos:
ntohs(*(uint16_t *) (ws_buf_ + pos_));
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.
The code did handle network byte order correctly, but it is true that ntohs and friends are more efficient on big-endian machines.
Adds constants and enums for readability. Adds proper handling of most opcodes including pings. Removes timeout settings.
|
||
using namespace atscppapi; | ||
|
||
#define SAY(a) std::cout << a << std::endl; |
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.
Please see the stuff we have available in atscppapi/Logger.h, such as TSDebug or creating a logger class.
With the C plugins we've had an experimental directory for plugins that were fairly new, we should probably consider adding this to a folder under atscppapi/examples/experimental for now and then we can always promote it later. Thanks for contributing. |
upgrade headers, framing and decoding, and a much simplified plugin.
Hi @ogoodman , I want to get this landed soon can you please just make one final change which puts it under an experimental/ folder in examples? After that I'm happy to commit this for you. Thanks |
also is there a jira ticket for this? |
@bgaff The new API should go through API review. IMHO it would be best to make a separate JIRA and pull request for the API changes. |
@ogoodman would you mind also starting a thread on dev@trafficserver.apache.org for API review? I can also kick off this discussion if you'd like. |
This needs a rebase as well before we can proceed. |
Also, repeating the question above, what is the Jira for this? |
There is no Jira. I just thought it might be of interest to people as another example plugin. If there is interest I can open one describing this as an enhancement. Shall I do that? |
Yeah, examples are great. So please create a Jira, if you are going to work on it. Any changes to APIs would need to go through API review though, so depending on what you are doing, you might want to split this up into multiple commits and/or multiple Jira's and PRs. |
Status on this PR? Is there a Jira? The branch has conflicts now, and likely might need a clang-format run as well. |
I'm going to close this particular PR now as it has become messy, doesn't reference any JIRA issue, and needs to be split into a PR on the TS API followed by one which adds the example to the C++ API. |
Add comment regarding missing header file to gzip.cc.
Co-Authored-By: Bryan Call <bcall@apache.org>
There are two commits. The first one adds an API function to determine whether a transaction is a websocket request and adds code to the InterceptPlugin to make it behave appropriately. The second one provides a working demo of a websocket handler.