SDK protocol versioning implemented. Protocol updated to version 1 which adds vendor string to controller request.
This commit is contained in:
parent
b0de49a107
commit
72da8f362c
11 changed files with 343 additions and 99 deletions
|
|
@ -72,6 +72,22 @@ unsigned short NetworkClient::GetPort()
|
||||||
return port_num;
|
return port_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int NetworkClient::GetProtocolVersion()
|
||||||
|
{
|
||||||
|
unsigned int protocol_version = 0;
|
||||||
|
|
||||||
|
if(server_protocol_version > OPENRGB_SDK_PROTOCOL_VERSION)
|
||||||
|
{
|
||||||
|
protocol_version = OPENRGB_SDK_PROTOCOL_VERSION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
protocol_version = server_protocol_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(protocol_version);
|
||||||
|
}
|
||||||
|
|
||||||
bool NetworkClient::GetConnected()
|
bool NetworkClient::GetConnected()
|
||||||
{
|
{
|
||||||
return(server_connected);
|
return(server_connected);
|
||||||
|
|
@ -203,13 +219,38 @@ void NetworkClient::ConnectionThreadFunction()
|
||||||
|
|
||||||
if(server_initialized == false && server_connected == true)
|
if(server_initialized == false && server_connected == true)
|
||||||
{
|
{
|
||||||
|
unsigned int timeout_counter = 0;
|
||||||
requested_controllers = 0;
|
requested_controllers = 0;
|
||||||
server_controller_count = 0;
|
server_controller_count = 0;
|
||||||
server_controller_count_received = false;
|
server_controller_count_received = false;
|
||||||
|
server_protocol_version_received = false;
|
||||||
|
|
||||||
//Wait for server to connect
|
//Wait for server to connect
|
||||||
std::this_thread::sleep_for(100ms);
|
std::this_thread::sleep_for(100ms);
|
||||||
|
|
||||||
|
//Request protocol version
|
||||||
|
SendRequest_ProtocolVersion();
|
||||||
|
|
||||||
|
//Wait up to 1s for protocol version reply
|
||||||
|
|
||||||
|
while(!server_protocol_version_received)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(5ms);
|
||||||
|
|
||||||
|
timeout_counter++;
|
||||||
|
|
||||||
|
/*-------------------------------------------------*\
|
||||||
|
| If no protocol version received within 1s, assume |
|
||||||
|
| the server doesn't support protocol versioning |
|
||||||
|
| and use protocol version 0 |
|
||||||
|
\*-------------------------------------------------*/
|
||||||
|
if(timeout_counter > 200)
|
||||||
|
{
|
||||||
|
server_protocol_version = 0;
|
||||||
|
server_protocol_version_received = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Once server is connected, send client string
|
//Once server is connected, send client string
|
||||||
SendData_ClientString();
|
SendData_ClientString();
|
||||||
|
|
||||||
|
|
@ -412,6 +453,10 @@ void NetworkClient::ListenThreadFunction()
|
||||||
ProcessReply_ControllerData(header.pkt_size, data, header.pkt_dev_idx);
|
ProcessReply_ControllerData(header.pkt_size, data, header.pkt_dev_idx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NET_PACKET_ID_REQUEST_PROTOCOL_VERSION:
|
||||||
|
ProcessReply_ProtocolVersion(header.pkt_size, data);
|
||||||
|
break;
|
||||||
|
|
||||||
case NET_PACKET_ID_DEVICE_LIST_UPDATED:
|
case NET_PACKET_ID_DEVICE_LIST_UPDATED:
|
||||||
ProcessRequest_DeviceListChanged();
|
ProcessRequest_DeviceListChanged();
|
||||||
break;
|
break;
|
||||||
|
|
@ -481,9 +526,9 @@ void NetworkClient::ProcessReply_ControllerCount(unsigned int data_size, char *
|
||||||
|
|
||||||
void NetworkClient::ProcessReply_ControllerData(unsigned int /*data_size*/, char * data, unsigned int dev_idx)
|
void NetworkClient::ProcessReply_ControllerData(unsigned int /*data_size*/, char * data, unsigned int dev_idx)
|
||||||
{
|
{
|
||||||
RGBController_Network * new_controller = new RGBController_Network(this, dev_idx);
|
RGBController_Network * new_controller = new RGBController_Network(this, dev_idx);
|
||||||
|
|
||||||
new_controller->ReadDeviceDescription((unsigned char *)data);
|
new_controller->ReadDeviceDescription((unsigned char *)data, GetProtocolVersion());
|
||||||
|
|
||||||
ControllerListMutex.lock();
|
ControllerListMutex.lock();
|
||||||
|
|
||||||
|
|
@ -502,6 +547,15 @@ void NetworkClient::ProcessReply_ControllerData(unsigned int /*data_size*/, char
|
||||||
controller_data_received = true;
|
controller_data_received = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkClient::ProcessReply_ProtocolVersion(unsigned int data_size, char * data)
|
||||||
|
{
|
||||||
|
if(data_size == sizeof(unsigned int))
|
||||||
|
{
|
||||||
|
memcpy(&server_protocol_version, data, sizeof(unsigned int));
|
||||||
|
server_protocol_version_received = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkClient::ProcessRequest_DeviceListChanged()
|
void NetworkClient::ProcessRequest_DeviceListChanged()
|
||||||
{
|
{
|
||||||
change_in_progress = true;
|
change_in_progress = true;
|
||||||
|
|
@ -563,36 +617,81 @@ void NetworkClient::SendData_ClientString()
|
||||||
|
|
||||||
void NetworkClient::SendRequest_ControllerCount()
|
void NetworkClient::SendRequest_ControllerCount()
|
||||||
{
|
{
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = 0;
|
request_hdr.pkt_dev_idx = 0;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_COUNT;
|
request_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_COUNT;
|
||||||
reply_hdr.pkt_size = 0;
|
request_hdr.pkt_size = 0;
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::SendRequest_ControllerData(unsigned int dev_idx)
|
void NetworkClient::SendRequest_ControllerData(unsigned int dev_idx)
|
||||||
{
|
{
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
|
unsigned int protocol_version;
|
||||||
|
|
||||||
controller_data_received = false;
|
controller_data_received = false;
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = dev_idx;
|
request_hdr.pkt_dev_idx = dev_idx;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_DATA;
|
request_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_DATA;
|
||||||
reply_hdr.pkt_size = 0;
|
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
if(server_protocol_version == 0)
|
||||||
|
{
|
||||||
|
request_hdr.pkt_size = 0;
|
||||||
|
|
||||||
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
request_hdr.pkt_size = sizeof(unsigned int);
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------*\
|
||||||
|
| Limit the protocol version to the highest supported by both |
|
||||||
|
| the client and the server. |
|
||||||
|
\*-------------------------------------------------------------*/
|
||||||
|
if(server_protocol_version > OPENRGB_SDK_PROTOCOL_VERSION)
|
||||||
|
{
|
||||||
|
protocol_version = OPENRGB_SDK_PROTOCOL_VERSION;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
protocol_version = server_protocol_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
|
send(client_sock, (char *)&protocol_version, sizeof(unsigned int), MSG_NOSIGNAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkClient::SendRequest_ProtocolVersion()
|
||||||
|
{
|
||||||
|
NetPacketHeader request_hdr;
|
||||||
|
unsigned int request_data;
|
||||||
|
|
||||||
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
|
request_hdr.pkt_dev_idx = 0;
|
||||||
|
request_hdr.pkt_id = NET_PACKET_ID_REQUEST_PROTOCOL_VERSION;
|
||||||
|
request_hdr.pkt_size = sizeof(unsigned int);
|
||||||
|
|
||||||
|
request_data = OPENRGB_SDK_PROTOCOL_VERSION;
|
||||||
|
|
||||||
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
|
send(client_sock, (char *)&request_data, sizeof(unsigned int), MSG_NOSIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size)
|
void NetworkClient::SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size)
|
||||||
|
|
@ -602,23 +701,23 @@ void NetworkClient::SendRequest_RGBController_ResizeZone(unsigned int dev_idx, i
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
int reply_data[2];
|
int request_data[2];
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = dev_idx;
|
request_hdr.pkt_dev_idx = dev_idx;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE;
|
request_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE;
|
||||||
reply_hdr.pkt_size = sizeof(reply_data);
|
request_hdr.pkt_size = sizeof(request_data);
|
||||||
|
|
||||||
reply_data[0] = zone;
|
request_data[0] = zone;
|
||||||
reply_data[1] = new_size;
|
request_data[1] = new_size;
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
send(client_sock, (char *)&reply_data, sizeof(reply_data), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_data, sizeof(request_data), MSG_NOSIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
void NetworkClient::SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||||
|
|
@ -628,18 +727,18 @@ void NetworkClient::SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, u
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = dev_idx;
|
request_hdr.pkt_dev_idx = dev_idx;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS;
|
request_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS;
|
||||||
reply_hdr.pkt_size = size;
|
request_hdr.pkt_size = size;
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
send(client_sock, (char *)data, size, 0);
|
send(client_sock, (char *)data, size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -650,18 +749,18 @@ void NetworkClient::SendRequest_RGBController_UpdateZoneLEDs(unsigned int dev_id
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = dev_idx;
|
request_hdr.pkt_dev_idx = dev_idx;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS;
|
request_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS;
|
||||||
reply_hdr.pkt_size = size;
|
request_hdr.pkt_size = size;
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -672,18 +771,18 @@ void NetworkClient::SendRequest_RGBController_UpdateSingleLED(unsigned int dev_i
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = dev_idx;
|
request_hdr.pkt_dev_idx = dev_idx;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED;
|
request_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED;
|
||||||
reply_hdr.pkt_size = size;
|
request_hdr.pkt_size = size;
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -694,18 +793,18 @@ void NetworkClient::SendRequest_RGBController_SetCustomMode(unsigned int dev_idx
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = dev_idx;
|
request_hdr.pkt_dev_idx = dev_idx;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE;
|
request_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE;
|
||||||
reply_hdr.pkt_size = 0;
|
request_hdr.pkt_size = 0;
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkClient::SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
void NetworkClient::SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||||
|
|
@ -715,17 +814,17 @@ void NetworkClient::SendRequest_RGBController_UpdateMode(unsigned int dev_idx, u
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader request_hdr;
|
||||||
|
|
||||||
reply_hdr.pkt_magic[0] = 'O';
|
request_hdr.pkt_magic[0] = 'O';
|
||||||
reply_hdr.pkt_magic[1] = 'R';
|
request_hdr.pkt_magic[1] = 'R';
|
||||||
reply_hdr.pkt_magic[2] = 'G';
|
request_hdr.pkt_magic[2] = 'G';
|
||||||
reply_hdr.pkt_magic[3] = 'B';
|
request_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
reply_hdr.pkt_dev_idx = dev_idx;
|
request_hdr.pkt_dev_idx = dev_idx;
|
||||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE;
|
request_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE;
|
||||||
reply_hdr.pkt_size = size;
|
request_hdr.pkt_size = size;
|
||||||
|
|
||||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
send(client_sock, (char *)&request_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ public:
|
||||||
bool GetConnected();
|
bool GetConnected();
|
||||||
const char * GetIP();
|
const char * GetIP();
|
||||||
unsigned short GetPort();
|
unsigned short GetPort();
|
||||||
|
unsigned int GetProtocolVersion();
|
||||||
bool GetOnline();
|
bool GetOnline();
|
||||||
|
|
||||||
void RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg);
|
void RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg);
|
||||||
|
|
@ -46,12 +47,15 @@ public:
|
||||||
|
|
||||||
void ProcessReply_ControllerCount(unsigned int data_size, char * data);
|
void ProcessReply_ControllerCount(unsigned int data_size, char * data);
|
||||||
void ProcessReply_ControllerData(unsigned int data_size, char * data, unsigned int dev_idx);
|
void ProcessReply_ControllerData(unsigned int data_size, char * data, unsigned int dev_idx);
|
||||||
|
void ProcessReply_ProtocolVersion(unsigned int data_size, char * data);
|
||||||
|
|
||||||
void ProcessRequest_DeviceListChanged();
|
void ProcessRequest_DeviceListChanged();
|
||||||
|
|
||||||
void SendData_ClientString();
|
void SendData_ClientString();
|
||||||
|
|
||||||
void SendRequest_ControllerCount();
|
void SendRequest_ControllerCount();
|
||||||
void SendRequest_ControllerData(unsigned int dev_idx);
|
void SendRequest_ControllerData(unsigned int dev_idx);
|
||||||
|
void SendRequest_ProtocolVersion();
|
||||||
|
|
||||||
void SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size);
|
void SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size);
|
||||||
|
|
||||||
|
|
@ -83,6 +87,8 @@ private:
|
||||||
bool server_initialized;
|
bool server_initialized;
|
||||||
unsigned int server_controller_count;
|
unsigned int server_controller_count;
|
||||||
bool server_controller_count_received;
|
bool server_controller_count_received;
|
||||||
|
unsigned int server_protocol_version;
|
||||||
|
bool server_protocol_version_received;
|
||||||
bool change_in_progress;
|
bool change_in_progress;
|
||||||
|
|
||||||
std::thread * ConnectionThread;
|
std::thread * ConnectionThread;
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,18 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/*-----------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Default OpenRGB SDK port is 6742 |
|
| OpenRGB SDK protocol version |
|
||||||
| This is "ORGB" on a phone keypad |
|
| |
|
||||||
\*-----------------------------------------*/
|
| 0: Initial (unversioned) protocol |
|
||||||
|
| 1: Add versioning, vendor string (Release 0.5) |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
#define OPENRGB_SDK_PROTOCOL_VERSION 1
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Default OpenRGB SDK port is 6742 |
|
||||||
|
| This is "ORGB" on a phone keypad |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
#define OPENRGB_SDK_PORT 6742
|
#define OPENRGB_SDK_PORT 6742
|
||||||
|
|
||||||
typedef struct NetPacketHeader
|
typedef struct NetPacketHeader
|
||||||
|
|
@ -30,6 +38,8 @@ enum
|
||||||
NET_PACKET_ID_REQUEST_CONTROLLER_COUNT = 0, /* Request RGBController device count from server */
|
NET_PACKET_ID_REQUEST_CONTROLLER_COUNT = 0, /* Request RGBController device count from server */
|
||||||
NET_PACKET_ID_REQUEST_CONTROLLER_DATA = 1, /* Request RGBController data block */
|
NET_PACKET_ID_REQUEST_CONTROLLER_DATA = 1, /* Request RGBController data block */
|
||||||
|
|
||||||
|
NET_PACKET_ID_REQUEST_PROTOCOL_VERSION = 40, /* Request OpenRGB SDK protocol version from server */
|
||||||
|
|
||||||
NET_PACKET_ID_SET_CLIENT_NAME = 50, /* Send client name string to server */
|
NET_PACKET_ID_SET_CLIENT_NAME = 50, /* Send client name string to server */
|
||||||
|
|
||||||
NET_PACKET_ID_DEVICE_LIST_UPDATED = 100, /* Indicate to clients that device list has updated */
|
NET_PACKET_ID_DEVICE_LIST_UPDATED = 100, /* Indicate to clients that device list has updated */
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,26 @@ const char * NetworkServer::GetClientIP(unsigned int client_num)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int NetworkServer::GetClientProtocolVersion(unsigned int client_num)
|
||||||
|
{
|
||||||
|
unsigned int result;
|
||||||
|
|
||||||
|
ServerClientsMutex.lock();
|
||||||
|
|
||||||
|
if(client_num < ServerClients.size())
|
||||||
|
{
|
||||||
|
result = ServerClients[client_num]->client_protocol_version;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerClientsMutex.unlock();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkServer::RegisterClientInfoChangeCallback(NetServerCallback new_callback, void * new_callback_arg)
|
void NetworkServer::RegisterClientInfoChangeCallback(NetServerCallback new_callback, void * new_callback_arg)
|
||||||
{
|
{
|
||||||
ClientInfoChangeCallbacks.push_back(new_callback);
|
ClientInfoChangeCallbacks.push_back(new_callback);
|
||||||
|
|
@ -482,7 +502,21 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NET_PACKET_ID_REQUEST_CONTROLLER_DATA:
|
case NET_PACKET_ID_REQUEST_CONTROLLER_DATA:
|
||||||
SendReply_ControllerData(client_sock, header.pkt_dev_idx);
|
{
|
||||||
|
unsigned int protocol_version = 0;
|
||||||
|
|
||||||
|
if(header.pkt_size == sizeof(unsigned int))
|
||||||
|
{
|
||||||
|
memcpy(&protocol_version, data, sizeof(unsigned int));
|
||||||
|
}
|
||||||
|
|
||||||
|
SendReply_ControllerData(client_sock, header.pkt_dev_idx, protocol_version);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case NET_PACKET_ID_REQUEST_PROTOCOL_VERSION:
|
||||||
|
SendReply_ProtocolVersion(client_sock);
|
||||||
|
ProcessRequest_ClientProtocolVersion(client_sock, header.pkt_size, data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NET_PACKET_ID_SET_CLIENT_NAME:
|
case NET_PACKET_ID_SET_CLIENT_NAME:
|
||||||
|
|
@ -609,6 +643,37 @@ listen_done:
|
||||||
ClientInfoChanged();
|
ClientInfoChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkServer::ProcessRequest_ClientProtocolVersion(SOCKET client_sock, unsigned int data_size, char * data)
|
||||||
|
{
|
||||||
|
unsigned int protocol_version = 0;
|
||||||
|
|
||||||
|
if(data_size == sizeof(unsigned int) && (data != NULL))
|
||||||
|
{
|
||||||
|
memcpy(&protocol_version, data, sizeof(unsigned int));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(protocol_version > OPENRGB_SDK_PROTOCOL_VERSION)
|
||||||
|
{
|
||||||
|
protocol_version = OPENRGB_SDK_PROTOCOL_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerClientsMutex.lock();
|
||||||
|
for(unsigned int this_idx = 0; this_idx < ServerClients.size(); this_idx++)
|
||||||
|
{
|
||||||
|
if(ServerClients[this_idx]->client_sock == client_sock)
|
||||||
|
{
|
||||||
|
ServerClients[this_idx]->client_protocol_version = protocol_version;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ServerClientsMutex.unlock();
|
||||||
|
|
||||||
|
/*-------------------------------------------------*\
|
||||||
|
| Client info has changed, call the callbacks |
|
||||||
|
\*-------------------------------------------------*/
|
||||||
|
ClientInfoChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkServer::ProcessRequest_ClientString(SOCKET client_sock, unsigned int /*data_size*/, char * data)
|
void NetworkServer::ProcessRequest_ClientString(SOCKET client_sock, unsigned int /*data_size*/, char * data)
|
||||||
{
|
{
|
||||||
ServerClientsMutex.lock();
|
ServerClientsMutex.lock();
|
||||||
|
|
@ -648,12 +713,12 @@ void NetworkServer::SendReply_ControllerCount(SOCKET client_sock)
|
||||||
send(client_sock, (const char *)&reply_data, sizeof(unsigned int), 0);
|
send(client_sock, (const char *)&reply_data, sizeof(unsigned int), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkServer::SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx)
|
void NetworkServer::SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx, unsigned int protocol_version)
|
||||||
{
|
{
|
||||||
if(dev_idx < controllers.size())
|
if(dev_idx < controllers.size())
|
||||||
{
|
{
|
||||||
NetPacketHeader reply_hdr;
|
NetPacketHeader reply_hdr;
|
||||||
unsigned char *reply_data = controllers[dev_idx]->GetDeviceDescription();
|
unsigned char *reply_data = controllers[dev_idx]->GetDeviceDescription(protocol_version);
|
||||||
unsigned int reply_size;
|
unsigned int reply_size;
|
||||||
|
|
||||||
memcpy(&reply_size, reply_data, sizeof(reply_size));
|
memcpy(&reply_size, reply_data, sizeof(reply_size));
|
||||||
|
|
@ -672,6 +737,26 @@ void NetworkServer::SendReply_ControllerData(SOCKET client_sock, unsigned int de
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkServer::SendReply_ProtocolVersion(SOCKET client_sock)
|
||||||
|
{
|
||||||
|
NetPacketHeader reply_hdr;
|
||||||
|
unsigned int reply_data;
|
||||||
|
|
||||||
|
reply_hdr.pkt_magic[0] = 'O';
|
||||||
|
reply_hdr.pkt_magic[1] = 'R';
|
||||||
|
reply_hdr.pkt_magic[2] = 'G';
|
||||||
|
reply_hdr.pkt_magic[3] = 'B';
|
||||||
|
|
||||||
|
reply_hdr.pkt_dev_idx = 0;
|
||||||
|
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_PROTOCOL_VERSION;
|
||||||
|
reply_hdr.pkt_size = sizeof(unsigned int);
|
||||||
|
|
||||||
|
reply_data = OPENRGB_SDK_PROTOCOL_VERSION;
|
||||||
|
|
||||||
|
send(client_sock, (const char *)&reply_hdr, sizeof(NetPacketHeader), 0);
|
||||||
|
send(client_sock, (const char *)&reply_data, sizeof(unsigned int), 0);
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkServer::SendRequest_DeviceListChanged(SOCKET client_sock)
|
void NetworkServer::SendRequest_DeviceListChanged(SOCKET client_sock)
|
||||||
{
|
{
|
||||||
NetPacketHeader pkt_hdr;
|
NetPacketHeader pkt_hdr;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ struct NetworkClientInfo
|
||||||
SOCKET client_sock;
|
SOCKET client_sock;
|
||||||
std::thread * client_listen_thread;
|
std::thread * client_listen_thread;
|
||||||
std::string client_string;
|
std::string client_string;
|
||||||
|
unsigned int client_protocol_version;
|
||||||
char client_ip[INET_ADDRSTRLEN];
|
char client_ip[INET_ADDRSTRLEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,6 +38,7 @@ public:
|
||||||
unsigned int GetNumClients();
|
unsigned int GetNumClients();
|
||||||
const char * GetClientString(unsigned int client_num);
|
const char * GetClientString(unsigned int client_num);
|
||||||
const char * GetClientIP(unsigned int client_num);
|
const char * GetClientIP(unsigned int client_num);
|
||||||
|
unsigned int GetClientProtocolVersion(unsigned int client_num);
|
||||||
|
|
||||||
void ClientInfoChanged();
|
void ClientInfoChanged();
|
||||||
void DeviceListChanged();
|
void DeviceListChanged();
|
||||||
|
|
@ -50,10 +52,12 @@ public:
|
||||||
void ConnectionThreadFunction();
|
void ConnectionThreadFunction();
|
||||||
void ListenThreadFunction(NetworkClientInfo * client_sock);
|
void ListenThreadFunction(NetworkClientInfo * client_sock);
|
||||||
|
|
||||||
|
void ProcessRequest_ClientProtocolVersion(SOCKET client_sock, unsigned int data_size, char * data);
|
||||||
void ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data);
|
void ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data);
|
||||||
|
|
||||||
void SendReply_ControllerCount(SOCKET client_sock);
|
void SendReply_ControllerCount(SOCKET client_sock);
|
||||||
void SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx);
|
void SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx, unsigned int protocol_version);
|
||||||
|
void SendReply_ProtocolVersion(SOCKET client_sock);
|
||||||
|
|
||||||
void SendRequest_DeviceListChanged(SOCKET client_sock);
|
void SendRequest_DeviceListChanged(SOCKET client_sock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ bool ProfileManager::SaveProfile(std::string profile_name)
|
||||||
\*---------------------------------------------------------*/
|
\*---------------------------------------------------------*/
|
||||||
for(std::size_t controller_index = 0; controller_index < controllers.size(); controller_index++)
|
for(std::size_t controller_index = 0; controller_index < controllers.size(); controller_index++)
|
||||||
{
|
{
|
||||||
unsigned char *controller_data = controllers[controller_index]->GetDeviceDescription();
|
unsigned char *controller_data = controllers[controller_index]->GetDeviceDescription(0);
|
||||||
unsigned int controller_size;
|
unsigned int controller_size;
|
||||||
|
|
||||||
memcpy(&controller_size, controller_data, sizeof(controller_size));
|
memcpy(&controller_size, controller_data, sizeof(controller_size));
|
||||||
|
|
@ -130,7 +130,7 @@ std::vector<RGBController*> ProfileManager::LoadProfileToList
|
||||||
|
|
||||||
RGBController_Dummy *temp_controller = new RGBController_Dummy();
|
RGBController_Dummy *temp_controller = new RGBController_Dummy();
|
||||||
|
|
||||||
temp_controller->ReadDeviceDescription(controller_data);
|
temp_controller->ReadDeviceDescription(controller_data, 0);
|
||||||
|
|
||||||
temp_controllers.push_back(temp_controller);
|
temp_controllers.push_back(temp_controller);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ RGBController::~RGBController()
|
||||||
delete DeviceCallThread;
|
delete DeviceCallThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char * RGBController::GetDeviceDescription()
|
unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_version)
|
||||||
{
|
{
|
||||||
unsigned int data_ptr = 0;
|
unsigned int data_ptr = 0;
|
||||||
unsigned int data_size = 0;
|
unsigned int data_size = 0;
|
||||||
|
|
@ -25,6 +25,7 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||||
| Calculate data size |
|
| Calculate data size |
|
||||||
\*---------------------------------------------------------*/
|
\*---------------------------------------------------------*/
|
||||||
unsigned short name_len = strlen(name.c_str()) + 1;
|
unsigned short name_len = strlen(name.c_str()) + 1;
|
||||||
|
unsigned short vendor_len = strlen(vendor.c_str()) + 1;
|
||||||
unsigned short description_len = strlen(description.c_str()) + 1;
|
unsigned short description_len = strlen(description.c_str()) + 1;
|
||||||
unsigned short version_len = strlen(version.c_str()) + 1;
|
unsigned short version_len = strlen(version.c_str()) + 1;
|
||||||
unsigned short serial_len = strlen(serial.c_str()) + 1;
|
unsigned short serial_len = strlen(serial.c_str()) + 1;
|
||||||
|
|
@ -44,6 +45,12 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||||
data_size += sizeof(data_size);
|
data_size += sizeof(data_size);
|
||||||
data_size += sizeof(device_type);
|
data_size += sizeof(device_type);
|
||||||
data_size += name_len + sizeof(name_len);
|
data_size += name_len + sizeof(name_len);
|
||||||
|
|
||||||
|
if(protocol_version >= 1)
|
||||||
|
{
|
||||||
|
data_size += vendor_len + sizeof(vendor_len);
|
||||||
|
}
|
||||||
|
|
||||||
data_size += description_len + sizeof(description_len);
|
data_size += description_len + sizeof(description_len);
|
||||||
data_size += version_len + sizeof(version_len);
|
data_size += version_len + sizeof(version_len);
|
||||||
data_size += serial_len + sizeof(serial_len);
|
data_size += serial_len + sizeof(serial_len);
|
||||||
|
|
@ -136,6 +143,18 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||||
strcpy((char *)&data_buf[data_ptr], name.c_str());
|
strcpy((char *)&data_buf[data_ptr], name.c_str());
|
||||||
data_ptr += name_len;
|
data_ptr += name_len;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Copy in vendor (size+data) if protocol 1 or higher |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
if(protocol_version >= 1)
|
||||||
|
{
|
||||||
|
memcpy(&data_buf[data_ptr], &vendor_len, sizeof(unsigned short));
|
||||||
|
data_ptr += sizeof(unsigned short);
|
||||||
|
|
||||||
|
strcpy((char *)&data_buf[data_ptr], vendor.c_str());
|
||||||
|
data_ptr += vendor_len;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------*\
|
/*---------------------------------------------------------*\
|
||||||
| Copy in description (size+data) |
|
| Copy in description (size+data) |
|
||||||
\*---------------------------------------------------------*/
|
\*---------------------------------------------------------*/
|
||||||
|
|
@ -405,7 +424,7 @@ unsigned char * RGBController::GetDeviceDescription()
|
||||||
return(data_buf);
|
return(data_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RGBController::ReadDeviceDescription(unsigned char* data_buf)
|
void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int protocol_version)
|
||||||
{
|
{
|
||||||
unsigned int data_ptr = 0;
|
unsigned int data_ptr = 0;
|
||||||
|
|
||||||
|
|
@ -427,6 +446,19 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf)
|
||||||
name = (char *)&data_buf[data_ptr];
|
name = (char *)&data_buf[data_ptr];
|
||||||
data_ptr += name_len;
|
data_ptr += name_len;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Copy in vendor if profile version is 1 or higher |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
if(protocol_version >= 1)
|
||||||
|
{
|
||||||
|
unsigned short vendor_len;
|
||||||
|
memcpy(&vendor_len, &data_buf[data_ptr], sizeof(unsigned short));
|
||||||
|
data_ptr += sizeof(unsigned short);
|
||||||
|
|
||||||
|
vendor = (char *)&data_buf[data_ptr];
|
||||||
|
data_ptr += vendor_len;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------*\
|
/*---------------------------------------------------------*\
|
||||||
| Copy in description |
|
| Copy in description |
|
||||||
\*---------------------------------------------------------*/
|
\*---------------------------------------------------------*/
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,8 @@ public:
|
||||||
int GetMode();
|
int GetMode();
|
||||||
void SetMode(int mode);
|
void SetMode(int mode);
|
||||||
|
|
||||||
unsigned char * GetDeviceDescription();
|
unsigned char * GetDeviceDescription(unsigned int protocol_version);
|
||||||
void ReadDeviceDescription(unsigned char* data_buf);
|
void ReadDeviceDescription(unsigned char* data_buf, unsigned int protocol_version);
|
||||||
|
|
||||||
unsigned char * GetModeDescription(int mode);
|
unsigned char * GetModeDescription(int mode);
|
||||||
void SetModeDescription(unsigned char* data_buf);
|
void SetModeDescription(unsigned char* data_buf);
|
||||||
|
|
|
||||||
5
main.cpp
5
main.cpp
|
|
@ -85,6 +85,11 @@ bool AttemptLocalConnection(std::vector<RGBController*> &rgb_controllers)
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
NetworkClient * client = new NetworkClient(rgb_controllers);
|
NetworkClient * client = new NetworkClient(rgb_controllers);
|
||||||
|
|
||||||
|
std::string titleString = "OpenRGB ";
|
||||||
|
titleString.append(VERSION_STRING);
|
||||||
|
|
||||||
|
client->SetName(titleString.c_str());
|
||||||
client->StartClient();
|
client->StartClient();
|
||||||
|
|
||||||
for(int timeout = 0; timeout < 10; timeout++)
|
for(int timeout = 0; timeout < 10; timeout++)
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,12 @@ void OpenRGBClientInfoPage::UpdateInfo()
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Set up the tree view header |
|
| Set up the tree view header |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
ui->ClientTree->setColumnCount(2);
|
ui->ClientTree->setColumnCount(3);
|
||||||
ui->ClientTree->header()->setStretchLastSection(false);
|
ui->ClientTree->header()->setStretchLastSection(false);
|
||||||
ui->ClientTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
ui->ClientTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
ui->ClientTree->setColumnWidth(1, 100);
|
ui->ClientTree->setColumnWidth(1, 100);
|
||||||
ui->ClientTree->setHeaderLabels(QStringList() << "Connected Clients" << "");
|
ui->ClientTree->setColumnWidth(2, 100);
|
||||||
|
ui->ClientTree->setHeaderLabels(QStringList() << "Connected Clients" << "Protocol Version" << "");
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Set up a signal mapper to handle disconnect buttons |
|
| Set up a signal mapper to handle disconnect buttons |
|
||||||
|
|
@ -92,17 +93,18 @@ void OpenRGBClientInfoPage::UpdateInfo()
|
||||||
{
|
{
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Create the top level tree widget items and display the|
|
| Create the top level tree widget items and display the|
|
||||||
| client IP addresses in them |
|
| client IP addresses and protocol versions in them |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
QTreeWidgetItem* new_top_item = new QTreeWidgetItem(ui->ClientTree);
|
QTreeWidgetItem* new_top_item = new QTreeWidgetItem(ui->ClientTree);
|
||||||
new_top_item->setText(0, QString::fromStdString(ResourceManager::get()->GetClients()[client_idx]->GetIP()));
|
new_top_item->setText(0, QString::fromStdString(ResourceManager::get()->GetClients()[client_idx]->GetIP()));
|
||||||
|
new_top_item->setText(1, QString::number(ResourceManager::get()->GetClients()[client_idx]->GetProtocolVersion()));
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Create the disconnect buttons and connect them to the |
|
| Create the disconnect buttons and connect them to the |
|
||||||
| signal mapper |
|
| signal mapper |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
QPushButton* new_button = new QPushButton( "Disconnect" );
|
QPushButton* new_button = new QPushButton( "Disconnect" );
|
||||||
ui->ClientTree->setItemWidget(new_top_item, 1, new_button);
|
ui->ClientTree->setItemWidget(new_top_item, 2, new_button);
|
||||||
|
|
||||||
connect(new_button, SIGNAL(clicked()), signalMapper, SLOT(map()));
|
connect(new_button, SIGNAL(clicked()), signalMapper, SLOT(map()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,14 +47,15 @@ void OpenRGBServerInfoPage::UpdateInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->ServerClientTree->clear();
|
ui->ServerClientTree->clear();
|
||||||
ui->ServerClientTree->setColumnCount(2);
|
ui->ServerClientTree->setColumnCount(3);
|
||||||
ui->ServerClientTree->setHeaderLabels(QStringList() << "Client IP" << "Client Name");
|
ui->ServerClientTree->setHeaderLabels(QStringList() << "Client IP" << "Protocol Version" << "Client Name");
|
||||||
for(unsigned int client_idx = 0; client_idx < network_server->GetNumClients(); client_idx++)
|
for(unsigned int client_idx = 0; client_idx < network_server->GetNumClients(); client_idx++)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem * new_item = new QTreeWidgetItem();
|
QTreeWidgetItem * new_item = new QTreeWidgetItem();
|
||||||
|
|
||||||
new_item->setText(0, network_server->GetClientIP(client_idx));
|
new_item->setText(0, network_server->GetClientIP(client_idx));
|
||||||
new_item->setText(1, network_server->GetClientString(client_idx));
|
new_item->setText(1, QString::number(network_server->GetClientProtocolVersion(client_idx)));
|
||||||
|
new_item->setText(2, network_server->GetClientString(client_idx));
|
||||||
|
|
||||||
ui->ServerClientTree->addTopLevelItem(new_item);
|
ui->ServerClientTree->addTopLevelItem(new_item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue