-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add unsolicited pong support with integration tests #20
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,21 @@ pplx::task<void> send_text_msg_helper(SocketClientClass& client, web::uri uri, t | |
return client.send(msg); | ||
} | ||
|
||
template<class SocketClientClass> | ||
pplx::task<void> send_pong_msg_helper(SocketClientClass& client, web::uri uri, test_websocket_server& server) | ||
{ | ||
server.next_message([](test_websocket_msg msg) // Handler to verify the message sent by the client. | ||
{ | ||
websocket_asserts::assert_message_equals(msg, "", test_websocket_message_type::WEB_SOCKET_PONG_TYPE); | ||
}); | ||
|
||
client.connect(uri).wait(); | ||
|
||
websocket_outgoing_message msg; | ||
msg.set_pong_message(); | ||
return client.send(msg); | ||
} | ||
|
||
pplx::task<void> send_msg_from_stream(websocket_client& client, | ||
test_websocket_server& server, | ||
web::uri uri, | ||
|
@@ -456,6 +471,25 @@ TEST_FIXTURE(uri_address, send_stream_binary_msg_no_length) | |
client.close().wait(); | ||
} | ||
|
||
// Send an unsolicited pong message to the server | ||
TEST_FIXTURE(uri_address, send_pong_msg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests will fail on WinRT since our WinRT websocket implementation does not support ping/pong messages. We should disable these tests on winrt (#if !defined(__cplusplus_winrt)). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am happy adding the ifdef myself, but I am also happy if you do that :) Let me know how you want me to proceed. |
||
{ | ||
test_websocket_server server; | ||
websocket_client client; | ||
send_pong_msg_helper(client, m_uri, server).wait(); | ||
client.close().wait(); | ||
} | ||
|
||
// Send an unsolicited pong message to the server with websocket_callback_client | ||
TEST_FIXTURE(uri_address, send_pong_msg_callback_client) | ||
{ | ||
test_websocket_server server; | ||
websocket_callback_client client; | ||
send_pong_msg_helper(client, m_uri, server).wait(); | ||
client.close().wait(); | ||
} | ||
|
||
|
||
} // SUITE(send_msg_tests) | ||
|
||
}}}} | ||
|
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.
FYI: This will fail on WinRT with an exception "Message Type not supported.".
I think this behavior is acceptable.
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.
Ok, great.