Skip to content

Commit

Permalink
Fix static function warning
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGro committed Dec 31, 2021
1 parent fa2b1ea commit cd1798a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
8 changes: 4 additions & 4 deletions libraries/networking/src/SockAddr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void SockAddr::handleLookupResult(const QHostInfo& hostInfo) {
}

QString SockAddr::toString() const {
return socketTypeToString(_socketType) + " " + _address.toString() + ":" + QString::number(_port);
return SocketTypeToString::socketTypeToString(_socketType) + " " + _address.toString() + ":" + QString::number(_port);
}

QString SockAddr::toShortString() const {
Expand All @@ -133,9 +133,9 @@ bool SockAddr::hasPrivateAddress() const {
}

QDebug operator<<(QDebug debug, const SockAddr& sockAddr) {
debug.nospace()
<< (sockAddr._socketType != SocketType::Unknown
? (socketTypeToString(sockAddr._socketType) + " ").toLocal8Bit().constData() : "")
debug.nospace()
<< (sockAddr._socketType != SocketType::Unknown
? (SocketTypeToString::socketTypeToString(sockAddr._socketType) + " ").toLocal8Bit().constData() : "")
<< sockAddr._address.toString().toLocal8Bit().constData() << ":" << sockAddr._port;
return debug.space();
}
Expand Down
18 changes: 10 additions & 8 deletions libraries/networking/src/SocketType.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ enum class SocketType : uint8_t {
WebRTC ///< WebRTC socket. A WebRTC data channel presented as a UDP-style socket.
};

/// @brief Returns the name of a SocketType value, e.g., <code>"WebRTC"</code>.
/// @param socketType The SocketType value.
/// @return The name of the SocketType value.
static QString socketTypeToString(SocketType socketType) {
static QStringList SOCKET_TYPE_STRINGS { "Unknown", "UDP", "WebRTC" };
return SOCKET_TYPE_STRINGS[(int)socketType];
}

class SocketTypeToString {
public:
/// @brief Returns the name of a SocketType value, e.g., <code>"WebRTC"</code>.
/// @param socketType The SocketType value.
/// @return The name of the SocketType value.
static QString socketTypeToString (SocketType socketType) {
static QStringList SOCKET_TYPE_STRINGS { "Unknown", "UDP", "WebRTC" };
return SOCKET_TYPE_STRINGS[(int)socketType];
}
};

/// @}

Expand Down
6 changes: 3 additions & 3 deletions libraries/networking/src/udt/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ void Socket::handleSocketError(SocketType socketType, QAbstractSocket::SocketErr
#endif
int pending = _networkSocket.bytesToWrite(socketType);
QString errorString;
QDebug(&errorString) << "udt::Socket (" << socketTypeToString(socketType) << _networkSocket.state(socketType)
<< ") error - " << wsaError << socketError << "(" << _networkSocket.errorString(socketType) << ")"
QDebug(&errorString) << "udt::Socket (" << SocketTypeToString::socketTypeToString(socketType) << _networkSocket.state(socketType)
<< ") error - " << wsaError << socketError << "(" << _networkSocket.errorString(socketType) << ")"
<< (pending ? "pending bytes:" : "pending:") << pending;

if (previousWsaError.exchange(wsaError) != wsaError) {
Expand All @@ -576,7 +576,7 @@ void Socket::handleSocketError(SocketType socketType, QAbstractSocket::SocketErr

void Socket::handleStateChanged(SocketType socketType, QAbstractSocket::SocketState socketState) {
if (socketState != QAbstractSocket::BoundState) {
qCDebug(networking) << socketTypeToString(socketType) << "socket state changed - state is now" << socketState;
qCDebug(networking) << SocketTypeToString::socketTypeToString(socketType) << "socket state changed - state is now" << socketState;
}
}

Expand Down

0 comments on commit cd1798a

Please sign in to comment.