27 , _authenticated(false)
46 , _authenticated(false)
79 connect(
_socket, SIGNAL( textMessageReceived(QString) ),
82 connect(
_socket, SIGNAL( binaryMessageReceived(QByteArray) ),
88 printf(
"WARNING! socket is invalid?\n");
94 connect(
_socket, SIGNAL( textMessageReceived(QString) ),
97 connect(
_socket, SIGNAL( binaryMessageReceived(QByteArray) ),
100 connect(
_socket, SIGNAL(
error(QAbstractSocket::SocketError) ),
101 this, SIGNAL(
error(QAbstractSocket::SocketError) ) );
139 QHostAddress a =
_socket->peerAddress();
169 int id = e->timerId();
216 {
VFS::WARN( QString(
"Socket disconnected... will attempt to reconnect."), 8,
className() );
305 qint64 w =
_socket->sendTextMessage(data);
308 if (w!=data.length())
309 {
VFS::ERROR( QString(
"Could not write all data to websocket! (%1/%2)").arg(w).arg(data.length()) );
311 printf(
"%s",qUtf8Printable(data));
327 qint64 w =
_socket->sendBinaryMessage(data);
329 if (w!=data.length())
330 {
VFS::ERROR( QString(
"Could not write all binary data to websocket! (%1/%2)").arg(w).arg(data.length()) );
354 QJsonDocument d = QJsonDocument::fromJson(message, &e);
355 if (e.error != QJsonParseError::NoError)
357 VFS::ERROR( QString(
"Unparseable command received from %1: %2\n%3").arg(
_address.toString()).arg(e.errorString()).arg(QString(message)), 0 );
359 return QJsonDocument();
VFS_node is the base class from which all other VFS_node classes derive.
virtual VFS_node * append(QString name, VFS_node *node, bool containerCheck=true, QString user="server")
Append a VFS_node as a child of this node.
QString uniqueChildName(QString name)
Generate a unique child name.
void mounted()
Emitted when a node is mount()ed.
void unmounted(VFS_node *self)
Emitted when a node is unmount()ed.
QString className()
Return the class name of a node.
The base class for all requests between nodes.
QString _path
the target path remnant... the remaining path element once the request has found its target
virtual bool isConnecting()
If the client will attempt to reconnect, return true.
bool _isClient
A client connection may not be created by a listening server, thus the second constructor.
virtual void submit(VFS_request *r)
Submit to the socket.
int _pingID
Connections can become stale; This is the ID of the ping timer.
VFS_websocket_client(QWebSocket *socket, VFS_websocket_server *server)
QString _wsurl
For client connections, the WebSocket address to connect to.
QHostAddress _address
The network address of the connected client.
quint16 _interval
The reconnect interval if disconnected.
virtual void authorized()
Notify the node that it has received authorization from some auth method.
void connected()
Connection has been made.
virtual void write(VFS_request *r)
Write to the socket.
virtual void socket_receive_text(QString message)
The socket has received a message in text mode.
void readyTextMessage(QString message)
A text message has been received.
virtual void socket_connected()
Slot called when the client is connected.
int _connectID
For client connections, the reconnect timerID.
virtual void socket_disconnected()
Slot called when the client is disconnected.
virtual ~VFS_websocket_client()
VFS_websocket_client destructor -.
VFS_websocket_server * _server
owning server
virtual void timerEvent(QTimerEvent *event)
Send the ping command.
void readyBinaryMessage(QByteArray message)
A binary message has been received.
virtual void init()
Initialize needed signal/slot connections.
virtual void close()
Close the socket if it is connected.
virtual bool isConnected()
If the client will attempt to reconnect, return true.
virtual bool writeBinary(QByteArray data)
Write binary data over the websocket.
void error(QAbstractSocket::SocketError)
There has been a socket error.
virtual void startPing()
Start the ping timer.
QWebSocket * _socket
client socket
void disconnected()
Connection has been lost.
virtual bool writeText(QString data)
Write text data over the websocket.
virtual void socket_receive_binary(QByteArray message)
VFS_websocket_client::socket_receive_binary.
virtual QJsonDocument receive(QByteArray message)
VFS_websocket_VFSclient::receive.
virtual bool isContainer()
A VFS_websocket_client cannot contain children.
A VFS_websocket server will listen for incoming websocket connections, optionally using ssl.
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.
message(m)
Change the message of an existing arrowMessage.