[wpiutil] Add HttpWebSocketServerConnection (#2505)

This is a derived class of HttpServerConnection that implements the
WebSocket upgrade pieces.  This combination is pretty common so is
worth refactoring here.
This commit is contained in:
Peter Johnson
2020-07-05 22:10:30 -07:00
committed by GitHub
parent b5a38001dd
commit c11ef442fb
3 changed files with 176 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "wpi/HttpWebSocketServerConnection.h" // NOLINT(build/include_order)
#include <gtest/gtest.h>
namespace wpi {
class HttpWebSocketServerConnectionTest
: public HttpWebSocketServerConnection<HttpWebSocketServerConnectionTest> {
public:
HttpWebSocketServerConnectionTest(std::shared_ptr<uv::Stream> stream,
ArrayRef<StringRef> protocols)
: HttpWebSocketServerConnection{stream, protocols} {}
void ProcessRequest() override { ++gotRequest; }
void ProcessWsUpgrade() override { ++gotUpgrade; }
int gotRequest = 0;
int gotUpgrade = 0;
};
} // namespace wpi