2 #include <QNetworkDatagram>
34 connect( &
_socket, SIGNAL( error(QAbstractSocket::SocketError) ),
35 this, SLOT(
socketError(QAbstractSocket::SocketError) ) );
67 if (
_mode.contains(
"r"))
72 bool l =
_socket.bind(QHostAddress::AnyIPv4,
_port, QUdpSocket::ShareAddress);
107 while (
_socket.hasPendingDatagrams())
109 QNetworkDatagram datagram =
_socket.receiveDatagram();
110 VFS::WARN( QString(
"Datagram: %1").arg( qUtf8Printable(datagram.data()) ) );
124 VFS::WARN( QString(
"(%1) Seems like something should happen here.").arg(
className()) );
138 qint64 l =
_socket.writeDatagram(d);
144 r->
_reason =
"Could not send datagram";
156 return QString(
"address: %1\nport: %2\nstate: %3").arg(
_address.toString()).arg(
_port).arg(
_socket.isOpen() ?
"open" :
"closed");
VFS_node is the base class from which all other VFS_node classes derive.
QString className()
Return the class name of a node.
The base class for all requests between nodes.
QString _reason
if something (probably bad) happened, this is the reason
bool _success
if the request was successfully completed
virtual QByteArray toJson(postID id=0, bool ignoreSuccess=false, bool includeInitialPath=false)
Serialize this request.
virtual void socketError(QAbstractSocket::SocketError error)
virtual bool isContainer()
A VFS_udp_socket cannot have children.
QString _mode
Either "rw" or "w".
virtual QString reportDetails()
Report details of this node.
virtual ~VFS_udp_socket()
Q_INVOKABLE VFS_udp_socket(QHostAddress multicast, quint16 port, QString mode="rw")
Create a VFS_udp_socket.
QHostAddress _address
Address used to listen or speak.
QUdpSocket _socket
UDP socket.
virtual void write(VFS_request *r)
Write to this node, which will emit UDP datagrams to the network.
static VFS * root()
Return the root node of the VFS filesystem.
static void LOG(QString message, int level=0, QString user="server")
Send a message to the VFS::_messages VFS_stream.
static void ERROR(QString message, int level=0, QString user="server")
Send a message to the VFS::_errors VFS_stream.
static void WARN(QString message, int level=0, QString user="server")
Send a message to the VFS::_warnings VFS_stream.