mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-03 17:58:49 +00:00
* Add a LibAudio, and move WAV file parsing there (via AWavFile and AWavLoader) * Add CLocalSocket, and CSocket::connect() variant for local address types. We make some small use of this in WindowServer (as that's where we modelled it from), but don't get too invasive as this PR is already quite large, and the WS I/O is a bit carefully done * Add an AClientConnection which will eventually be used to talk to AudioServer (and make use of it in Piano, though right now it really doesn't do anything except connect, using our new CLocalSocket...)
48 lines
1 KiB
C++
48 lines
1 KiB
C++
#pragma once
|
|
|
|
#include <AK/IPv4Address.h>
|
|
|
|
class CSocketAddress {
|
|
public:
|
|
enum class Type {
|
|
Invalid,
|
|
IPv4,
|
|
Local
|
|
};
|
|
|
|
CSocketAddress() {}
|
|
CSocketAddress(const IPv4Address& address)
|
|
: m_type(Type::IPv4)
|
|
, m_ipv4_address(address)
|
|
{
|
|
}
|
|
|
|
static CSocketAddress local(const String& address)
|
|
{
|
|
CSocketAddress addr;
|
|
addr.m_type = Type::Local;
|
|
addr.m_local_address = address;
|
|
return addr;
|
|
}
|
|
|
|
Type type() const { return m_type; }
|
|
bool is_valid() const { return m_type != Type::Invalid; }
|
|
IPv4Address ipv4_address() const { return m_ipv4_address; }
|
|
|
|
String to_string() const
|
|
{
|
|
switch (m_type) {
|
|
case Type::IPv4:
|
|
return m_ipv4_address.to_string();
|
|
case Type::Local:
|
|
return m_local_address;
|
|
default:
|
|
return "[CSocketAddress]";
|
|
}
|
|
}
|
|
|
|
private:
|
|
Type m_type { Type::Invalid };
|
|
IPv4Address m_ipv4_address;
|
|
String m_local_address;
|
|
};
|