Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
bae98e17
Commit
bae98e17
authored
Feb 07, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add convenience functions and fix some type errors
parent
c6fbe7ad
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
9 deletions
+31
-9
libcaf_net/caf/net/tcp_stream_socket.hpp
libcaf_net/caf/net/tcp_stream_socket.hpp
+3
-3
libcaf_net/caf/net/web_socket/client.hpp
libcaf_net/caf/net/web_socket/client.hpp
+16
-2
libcaf_net/caf/net/web_socket/server.hpp
libcaf_net/caf/net/web_socket/server.hpp
+4
-4
libcaf_net/src/tcp_stream_socket.cpp
libcaf_net/src/tcp_stream_socket.cpp
+8
-0
No files found.
libcaf_net/caf/net/tcp_stream_socket.hpp
View file @
bae98e17
...
...
@@ -26,11 +26,11 @@ struct CAF_NET_EXPORT tcp_stream_socket : stream_socket {
expected
<
tcp_stream_socket
>
CAF_NET_EXPORT
make_connected_tcp_stream_socket
(
ip_endpoint
node
);
/// Create
a `tcp_stream_socket` connected to `auth`
.
/// @param
node
Host and port of the remote node.
/// Create
s a `tcp_stream_socket` connected to @p auth
.
/// @param
auth
Host and port of the remote node.
/// @returns The connected socket or an error.
/// @relates tcp_stream_socket
expected
<
tcp_stream_socket
>
CAF_NET_EXPORT
make_connected_tcp_stream_socket
(
const
uri
::
authority_type
&
node
);
make_connected_tcp_stream_socket
(
const
uri
::
authority_type
&
auth
);
}
// namespace caf::net
libcaf_net/caf/net/web_socket/client.hpp
View file @
bae98e17
...
...
@@ -4,14 +4,13 @@
#pragma once
#include <algorithm>
#include "caf/byte_span.hpp"
#include "caf/detail/base64.hpp"
#include "caf/error.hpp"
#include "caf/hash/sha1.hpp"
#include "caf/logger.hpp"
#include "caf/net/fwd.hpp"
#include "caf/net/message_flow_bridge.hpp"
#include "caf/net/receive_policy.hpp"
#include "caf/net/web_socket/framing.hpp"
#include "caf/net/web_socket/handshake.hpp"
...
...
@@ -20,6 +19,8 @@
#include "caf/tag/mixed_message_oriented.hpp"
#include "caf/tag/stream_oriented.hpp"
#include <algorithm>
namespace
caf
::
net
::
web_socket
{
/// Implements the client part for the WebSocket Protocol as defined in RFC
...
...
@@ -179,4 +180,17 @@ private:
settings
cfg_
;
};
template
<
template
<
class
>
class
Transport
=
stream_transport
,
class
Socket
,
class
T
,
class
Trait
>
void
run_client
(
multiplexer
&
mpx
,
Socket
fd
,
handshake
hs
,
async
::
consumer_resource
<
T
>
in
,
async
::
producer_resource
<
T
>
out
,
Trait
trait
)
{
using
app_t
=
message_flow_bridge
<
T
,
Trait
,
tag
::
mixed_message_oriented
>
;
using
stack_t
=
Transport
<
client
<
app_t
>>
;
auto
mgr
=
make_socket_manager
<
stack_t
>
(
fd
,
&
mpx
,
std
::
move
(
hs
),
std
::
move
(
trait
));
mgr
->
top_layer
().
connect_flows
(
mgr
.
get
(),
std
::
move
(
in
),
std
::
move
(
out
));
mpx
.
init
(
mgr
);
}
}
// namespace caf::net::web_socket
libcaf_net/caf/net/web_socket/server.hpp
View file @
bae98e17
...
...
@@ -4,8 +4,6 @@
#pragma once
#include <algorithm>
#include "caf/byte_span.hpp"
#include "caf/error.hpp"
#include "caf/logger.hpp"
...
...
@@ -23,6 +21,8 @@
#include "caf/tag/mixed_message_oriented.hpp"
#include "caf/tag/stream_oriented.hpp"
#include <algorithm>
namespace
caf
::
net
::
web_socket
{
/// Implements the server part for the WebSocket Protocol as defined in RFC
...
...
@@ -385,11 +385,11 @@ public:
return
decorated
().
convert
(
x
,
text
);
}
bool
convert
(
const_byte_span
bytes
,
int32_t
&
x
)
{
bool
convert
(
const_byte_span
bytes
,
value_type
&
x
)
{
return
decorated
().
convert
(
bytes
,
x
);
}
bool
convert
(
string_view
text
,
int32_t
&
x
)
{
bool
convert
(
string_view
text
,
value_type
&
x
)
{
return
decorated
().
convert
(
text
,
x
);
}
...
...
libcaf_net/src/tcp_stream_socket.cpp
View file @
bae98e17
...
...
@@ -83,4 +83,12 @@ make_connected_tcp_stream_socket(const uri::authority_type& node) {
return
make_error
(
sec
::
cannot_connect_to_node
,
to_string
(
node
));
}
expected
<
tcp_stream_socket
>
make_connected_tcp_stream_socket
(
std
::
string
host
,
uint16_t
port
)
{
uri
::
authority_type
auth
;
auth
.
host
=
std
::
move
(
host
);
auth
.
port
=
port
;
return
make_connected_tcp_stream_socket
(
auth
);
}
}
// namespace caf::net
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment