Ocean
Loading...
Searching...
No Matches
ConnectionlessServer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef FACEBOOK_NETWORK_CONNECTIONLESS_SERVER_H
9#define FACEBOOK_NETWORK_CONNECTIONLESS_SERVER_H
10
14
15#include "ocean/base/Callback.h"
16
17namespace Ocean
18{
19
20namespace Network
21{
22
23/**
24 * This class is the base class for all connectionless server.
25 * @ingroup network
26 */
27class OCEAN_NETWORK_EXPORT ConnectionlessServer :
28 virtual public ConnectionlessClient,
29 virtual public Server
30{
31 public:
32
33 /**
34 * Definition of a data callback function.
35 * Parameter 0 provides the address of the sender
36 * Parameter 1 provides the port of the sender
37 * Parameter 2 provides the buffer that has been received, must be copied
38 * Parameter 3 provides the size of the received buffer, in bytes
39 */
41
42 public:
43
44 /**
45 * Destructs a connectionless server object.
46 */
48
49 /**
50 * Sets the receive data callback function.
51 * @param callback The callback function to be called if a new message arrives
52 */
53 inline void setReceiveCallback(const ReceiveCallback& callback);
54
55 protected:
56
57 /**
58 * Creates a new connectionless server object.
59 */
61
62 /**
63 * The scheduler event function.
64 * Socket::onScheduler().
65 */
66 bool onScheduler() override;
67
68 protected:
69
70 /// Data callback function called on new message arrivals.
72};
73
75{
76 const ScopedLock scopedLock(lock_);
77
78 receiveCallback_ = callback;
79}
80
81}
82
83}
84
85#endif // FACEBOOK_NETWORK_CONNECTIONLESS_SERVER_H
This class implements a container for callback functions.
Definition Callback.h:3456
This class is the base class for all connectionless clients.
Definition ConnectionlessClient.h:27
This class is the base class for all connectionless server.
Definition ConnectionlessServer.h:30
~ConnectionlessServer() override
Destructs a connectionless server object.
ConnectionlessServer()
Creates a new connectionless server object.
void setReceiveCallback(const ReceiveCallback &callback)
Sets the receive data callback function.
Definition ConnectionlessServer.h:74
ReceiveCallback receiveCallback_
Data callback function called on new message arrivals.
Definition ConnectionlessServer.h:71
bool onScheduler() override
The scheduler event function.
Callback< void, const Address4 &, const Port &, const void *, const size_t > ReceiveCallback
Definition of a data callback function.
Definition ConnectionlessServer.h:40
This class is the base class for all server.
Definition Server.h:26
Lock lock_
Socket lock.
Definition Socket.h:187
This class implements a scoped lock object for recursive lock objects.
Definition Lock.h:135
The namespace covering the entire Ocean framework.
Definition Accessor.h:15