Project
Loading...
Searching...
No Matches
DPLWebSocket.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_DPLWEBSOCKET_H_
12#define O2_FRAMEWORK_DPLWEBSOCKET_H_
13
15#include <uv.h>
16#include "HTTPParser.h"
17#include <memory>
18#include <string>
19#include <map>
20#include <functional>
21#include <atomic>
22
23class uv_stream_s;
24
25namespace o2::framework
26{
27
28struct DeviceSpec;
29struct DriverServerContext;
30struct DriverClientContext;
31
32struct WSError {
33 int code;
34 std::string message;
35};
36
37struct WSDPLHandler : public HTTPParser {
44 WSDPLHandler(uv_stream_t* stream, DriverServerContext* context);
45 virtual ~WSDPLHandler() = default;
46 void method(std::string_view const& s) override;
47 void target(std::string_view const& s) override;
48 void header(std::string_view const& k, std::string_view const& v) override;
49 void endHeaders() override;
51 void body(char* data, size_t s) override;
53 void write(char const*, size_t);
54
56 void write(std::vector<uv_buf_t>& outputs);
57
59 void error(int code, char const* message);
60
61 std::unique_ptr<WebSocketHandler> mHandler;
62 bool mHandshaken = false;
63 uv_stream_t* mStream = nullptr;
64 std::map<std::string, std::string> mHeaders;
65 std::string mTarget;
67};
68
69struct WSDPLClient : public HTTPParser {
76 uv_stream_t* stream,
77 std::function<void()> handshake,
78 std::unique_ptr<WebSocketHandler> handler);
79
80 void replyVersion(std::string_view const& s) override;
81 void replyCode(std::string_view const& s) override;
82 void header(std::string_view const& k, std::string_view const& v) override;
83 void endHeaders() override;
85 void body(char* data, size_t s) override;
87 void write(char const*, size_t);
88
90 void write(std::vector<uv_buf_t>& outputs);
91
94 void write(std::vector<uv_buf_t>& outputs, std::vector<char*>& freeList);
95
97 void dumpHeaders();
98 void sendHandshake();
99 bool isHandshaken() { return mHandshaken; }
100
101 std::string mNonce;
102 std::atomic<bool> mHandshaken = false;
103 std::function<void()> mHandshake;
104 std::unique_ptr<DriverClientContext> mContext;
105 std::unique_ptr<WebSocketHandler> mHandler;
106 uv_stream_t* mStream = nullptr;
107 std::map<std::string, std::string> mHeaders;
108};
109} // namespace o2::framework
110
111#endif // O2_FRAMEWORK_DPL_WEBSOCKET_H_
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
const GLdouble * v
Definition glcorearb.h:832
GLenum target
Definition glcorearb.h:1641
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
GLuint GLuint stream
Definition glcorearb.h:1806
GLint ref
Definition glcorearb.h:291
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::unique_ptr< WebSocketHandler > mHandler
void replyVersion(std::string_view const &s) override
std::function< void()> mHandshake
std::atomic< bool > mHandshaken
void connect(ServiceRegistryRef ref, uv_stream_t *stream, std::function< void()> handshake, std::unique_ptr< WebSocketHandler > handler)
std::unique_ptr< DriverClientContext > mContext
void body(char *data, size_t s) override
Actual handling of WS frames happens inside here.
void replyCode(std::string_view const &s) override
void dumpHeaders()
Dump headers.
void write(char const *, size_t)
Helper to write a message to the server.
void header(std::string_view const &k, std::string_view const &v) override
std::map< std::string, std::string > mHeaders
void method(std::string_view const &s) override
void body(char *data, size_t s) override
Actual handling of WS frames happens inside here.
void header(std::string_view const &k, std::string_view const &v) override
virtual ~WSDPLHandler()=default
DriverServerContext * mServerContext
std::unique_ptr< WebSocketHandler > mHandler
void write(char const *, size_t)
Helper to write a message to the associated client.
std::map< std::string, std::string > mHeaders