Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add protocol support to WebSocketClient#121

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
emsi wants to merge2 commits intoarduino-libraries:master
base:master
Choose a base branch
Loading
fromemsi:master
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletionssrc/WebSocketClient.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ WebSocketClient::WebSocketClient(Client& aClient, const IPAddress& aServerAddres
{
}

int WebSocketClient::begin(const char* aPath)
int WebSocketClient::begin(const char* aPath, const char* protocol=NULL)
{
// start the GET request
beginRequest();
Expand All@@ -51,6 +51,9 @@ int WebSocketClient::begin(const char* aPath)
sendHeader("Connection", "Upgrade");
sendHeader("Sec-WebSocket-Key", base64RandomKey);
sendHeader("Sec-WebSocket-Version", "13");
if (protocol) {
sendHeader("Sec-WebSocket-Protocol", protocol);
}
endRequest();

status = responseStatusCode();
Expand All@@ -67,9 +70,19 @@ int WebSocketClient::begin(const char* aPath)
return (status == 101) ? 0 : status;
}

int WebSocketClient::begin(const String& aPath, const String& protocol)
{
return begin(aPath, protocol);
}

int WebSocketClient::begin(const char* aPath)
{
return begin(aPath, NULL);
}

int WebSocketClient::begin(const String& aPath)
{
return begin(aPath.c_str());
return begin(aPath.c_str(), NULL);
}

int WebSocketClient::beginMessage(int aType)
Expand Down
2 changes: 2 additions & 0 deletionssrc/WebSocketClient.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,8 @@ class WebSocketClient : public HttpClient
*/
int begin(const char* aPath = "/");
int begin(const String& aPath);
int begin(const char* aPath, const char* protocol);
int begin(const String& aPath, const String& protocol);

/** Begin to send a message of type (TYPE_TEXT or TYPE_BINARY)
Use the write or Stream API's to set message content, followed by endMessage
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp