aboutsummaryrefslogtreecommitdiff
path: root/zenserver/testing/httptest.cpp
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2022-02-18 14:48:41 +0100
committerPer Larsson <[email protected]>2022-02-18 14:48:41 +0100
commit08cc02bf1b5cad75ed7b97c0dc7cfc082da537c4 (patch)
tree8fd8e7189c9807280003eabb3040cb35db2e5cd4 /zenserver/testing/httptest.cpp
parentWeb socket client is shared between I/O thead and client. (diff)
downloadzen-08cc02bf1b5cad75ed7b97c0dc7cfc082da537c4.tar.xz
zen-08cc02bf1b5cad75ed7b97c0dc7cfc082da537c4.zip
Basic websocket service and test.
Diffstat (limited to 'zenserver/testing/httptest.cpp')
-rw-r--r--zenserver/testing/httptest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/zenserver/testing/httptest.cpp b/zenserver/testing/httptest.cpp
index 230d5d6c5..41a4f064b 100644
--- a/zenserver/testing/httptest.cpp
+++ b/zenserver/testing/httptest.cpp
@@ -136,6 +136,33 @@ HttpTestingService::HandlePackageRequest(HttpServerRequest& HttpServiceRequest)
return (InsertResult.first->second = new PackageHandler(*this, RequestId)).Get();
}
+bool
+HttpTestingService::HandleMessage(WebSocketId SocketId, const CbPackage& Msg)
+{
+ using namespace std::literals;
+
+ CbObject Request = Msg.GetObject();
+
+ CbObjectView Header = Request["Header"sv].AsObjectView();
+ std::string_view Method = Header["Method"].AsString();
+ const uint64_t CorrelationId = Header["CorrelationId"].AsUInt64();
+
+ if (Method != "TestHelloZen"sv)
+ {
+ return false;
+ }
+
+ CbObjectWriter Response;
+ Response.BeginObject("Header");
+ Response << "CorrelationId"sv << CorrelationId;
+ Response.EndObject();
+ Response.AddString("Result"sv, "Hello Friend!!");
+
+ PublishMessage(SocketId, Response.Save());
+
+ return true;
+}
+
//////////////////////////////////////////////////////////////////////////
HttpTestingService::PackageHandler::PackageHandler(HttpTestingService& Svc, uint32_t RequestId) : m_Svc(Svc), m_RequestId(RequestId)