forked from jamulussoftware/jamulus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJamulusBridge.h
More file actions
65 lines (55 loc) · 2.26 KB
/
JamulusBridge.h
File metadata and controls
65 lines (55 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include <QObject>
#include <QCoreApplication>
#include "client.h"
#include "global.h"
#include <juce_gui_basics/juce_gui_basics.h>
#include <functional>
#include <iostream>
class JamulusBridge : public QObject
{
Q_OBJECT
public:
JamulusBridge(CClient* client,
std::function<void(const CVector<CServerInfo>&)> onServerList,
std::function<void(const CVector<CChannelInfo>&)> onClientList,
std::function<void(const CVector<uint16_t>&)> onLevels)
: pClient(client),
serverListCb(onServerList),
clientListCb(onClientList),
levelsCb(onLevels)
{
if (pClient)
{
// Server List (Directory)
connect(pClient, &CClient::CLServerListReceived, this, &JamulusBridge::OnCLServerListReceived);
// Client List (Connected participants)
connect(pClient, &CClient::ConClientListMesReceived, this, &JamulusBridge::OnConClientListMesReceived);
// Levels
connect(pClient, &CClient::CLChannelLevelListReceived, this, &JamulusBridge::OnCLChannelLevelListReceived);
std::cout << "[JamulusBridge] Connected to CClient signals." << std::endl;
}
}
public slots:
void OnCLServerListReceived(CHostAddress InetAddr, CVector<CServerInfo> vecServerInfo)
{
std::cout << "[JamulusBridge] OnCLServerListReceived: " << vecServerInfo.Size() << " servers." << std::endl;
if (serverListCb) serverListCb(vecServerInfo);
}
void OnConClientListMesReceived(CVector<CChannelInfo> vecChanInfo)
{
std::cout << "[JamulusBridge] OnConClientListMesReceived: " << vecChanInfo.Size() << " clients." << std::endl;
if (clientListCb) clientListCb(vecChanInfo);
}
void OnCLChannelLevelListReceived(CHostAddress InetAddr, CVector<uint16_t> vecLevelList)
{
// Level updates are frequent, uncomment if needed
// std::cout << "[JamulusBridge] Levels received." << std::endl;
if (levelsCb) levelsCb(vecLevelList);
}
private:
CClient* pClient;
std::function<void(const CVector<CServerInfo>&)> serverListCb;
std::function<void(const CVector<CChannelInfo>&)> clientListCb;
std::function<void(const CVector<uint16_t>&)> levelsCb;
};