1 #ifndef VFS_REMOTOSERVER_H
2 #define VFS_REMOTOSERVER_H
4 #include <QJsonDocument>
15 Q_INVOKABLE
explicit VFS_remotoserver(quint16 port, QString auth, QString sessions, QHostAddress addr=QHostAddress::Any, QWebSocketServer::SslMode ssl=QWebSocketServer::NonSecureMode, QString sslCertPath=
"", QString sslKeyPath=
"");
43 virtual QJsonDocument
receive(QByteArray data);
48 bool writeUIDiff(QString path, QJsonDocument
diff, QString user,
bool binary=
false);
49 bool writeUIRead(QString path, QJsonDocument data, QJsonObject
metadata,
bool binary=
false);
51 bool writeUIRM(QString path,
bool binary=
false);
53 bool writeUILS(QString
id, QString path, QJsonDocument data, QJsonObject
metadata,
bool binary=
false);
59 bool writeError(QString message,
bool binary=
false);
60 bool writeRequestSuccess(QString command, QString path, QJsonDocument data=QJsonDocument(), QJsonObject
metadata=QJsonObject(),
bool binary=
false);
61 bool writeRequestError(QString command, QString path, QString reason,
bool binary=
false);
VFS_node is the base class from which all other VFS_node classes derive.
virtual void metadata(VFS_request *r)
Fetch the metadata of this node.
static QString code(QString nodename, QString libname, QString &error)
Fetch code or any other resource from a node.
void diff(VFS_node *origin, VFS_request *t)
Emit a diff, which will trigger notifySubscribers() for a mounted node.
A subclass of VFS_websocket_client that implements the remoto websocket protocol and handles requests...
virtual QJsonDocument receive(QByteArray data)
Receive a message from a connected websocket client.
QString _type
The remote client type, which may be "browser" or "unity" or any other id string.
virtual void authenticate(QJsonDocument d)
Authenticate a user using VFS_websocket_server::authenticate().
bool writeUICode(QString libname, QString code, QString error, bool binary=false)
Write a VFS_request::code response to a connected client.
bool writeRequestError(QString command, QString path, QString reason, bool binary=false)
Write a requesterror command to a connected client.
QMap< VFS_node *, QString > _sourcePathMap
A map relating path requests from a client to path requests on the VFS.
bool writeUIRequestLock(QString path, QJsonDocument data, bool binary=false)
Write the results of a VFS_request::requestlock to a connected client.
bool writeError(QString message, bool binary=false)
Write an error state to a connected client.
void addSourcePathMap(VFS_node *source, QString path)
Add a VFS_remotoserver_client::_sourcePathMap entry for a path from a client's perspective to a VFS_n...
bool writeUIWrite(QString path, QJsonDocument data, QJsonObject metadata, bool binary=false)
Write data to a connected client.
virtual void applyDiff(VFS_request *t)
Apply a diff to this node.
bool writeUIReleaseLock(QString path, QJsonDocument data, bool binary=false)
Write the results of a VFS_request::releaselock to a connected client.
bool writeUIMetadata(QString path, QJsonObject metadata, bool binary=false)
Write a VFS_request::metadata response to a connected client.
QJsonObject _parameters
Parameters provided during the auth process.
virtual void receiveResponse(VFS_request *t)
Receive a response from an issueRequest().
bool writeUIRead(QString path, QJsonDocument data, QJsonObject metadata, bool binary=false)
Send the results of a VFS_request::read command to a client.
QJsonObject parameters() const
Return the parameters provided to this client when authentication was granted.
virtual ~VFS_remotoserver_client()
VFS_session * _session
The session associated with this client connection.
virtual void write(VFS_request *r)
Write form or interface information back to a user.
QString _user
The authenticated client's username.
bool writeUICodeDirectory(QJsonObject o, QString error, bool binary=false)
Write a VFS_request::codeDirectory response to a connected client.
virtual void removeSourcePathMap(VFS_node *n)
Remove a VFS_remotoserver_client::_sourcePathMap entry for a VFS_node.
virtual VFS_node * find(VFS_request *r)
VFS_remotoserver_client cannot contain children, but instead points to a websocket client,...
virtual QString reportDetails()
Report the _user and _type of a connected client.
virtual VFS_request * createRequest(VFS_request::requestType type, QString path, QString user="unknown", QJsonDocument data=QJsonDocument(), QJsonObject metadata=QJsonObject(), bool dontDelete=false)
Create a VFS_remotoserver_request to service a request received from a client.
bool writeRequestSuccess(QString command, QString path, QJsonDocument data=QJsonDocument(), QJsonObject metadata=QJsonObject(), bool binary=false)
VFS_remotoserver_client::writeRequestSuccess.
bool writeUIDiff(QString path, QJsonDocument diff, QString user, bool binary=false)
Send a diff command to a client when something interesting happens on a subscribed VFS_node.
bool writeUIRM(QString path, bool binary=false)
Send an RM command to a connected client.
virtual void rm(VFS_request *r)
Send an RM command to a user.
bool writeUISubscribe(QString path, QJsonDocument data, QJsonObject metadata, bool binary=false)
Write a VFS_request::subscribe response to a connected client.
VFS_remotoserver_client(QWebSocket *socket, VFS_websocket_server *server)
bool writeUILS(QString id, QString path, QJsonDocument data, QJsonObject metadata, bool binary=false)
Write a VFS_request::ls response to a connected client.
A subclass of VFS_request used for websocket (VFS_remotoserver) communication.
bool _binary
Binary mode flag for websocket messages.
virtual void execute()
Dynamically cast the _origin node to a VFS_remotoserver_client and write the results of a request to ...
virtual ~VFS_remotoserver_request()
VFS_remotoserver_request(VFS_request::requestType type, VFS_remotoserver_client *origin, QString path="", QString user="unknown", QJsonDocument data=QJsonDocument(), QJsonObject metadata=QJsonObject(), bool binary=false)
VFS_remotoserver is a subclass of VFS_websocket_server.
virtual void clientTextMessage(QString message)
The client has received as text websocket message.
Q_INVOKABLE VFS_remotoserver(quint16 port, QString auth, QString sessions, QHostAddress addr=QHostAddress::Any, QWebSocketServer::SslMode ssl=QWebSocketServer::NonSecureMode, QString sslCertPath="", QString sslKeyPath="")
virtual QString reportDetails()
Report the _port number.
virtual VFS_websocket_client * createWebsocketClient(QWebSocket *s)
Create a VFS_remotoserver_client to host a new connection.
static int count
The global count of VFS_remotoserver instances, used to create a config.json file if needed.
virtual void clientBinaryMessage(QByteArray message)
The client has received as binary websocket message.
virtual ~VFS_remotoserver()
The base class for all requests between nodes.
requestType
Requests perform one of these actions.
@ metadata
read metadata (6)
The VFS_session object represents a single session.
A VFS_node that manages a QWebSocket connection.
void error(QAbstractSocket::SocketError)
There has been a socket error.
A VFS_websocket server will listen for incoming websocket connections, optionally using ssl.