PDA

View Full Version : Model over the network



NoRulez
9th July 2009, 14:47
Hey @all,

is there a way to transport a model over the network? For Example: I've a client which are connected with a server (QTcpServer), this server is connected to a database.

Now i would like to use a QSqlQueryModel or similar in my client, but the problem now is that the client hasn't direct access to the database, the clients only have the connection to the server.

Hope someone can understood what I mean and could help me
Best Regards

NoRulez

jpujolf
13th July 2009, 08:40
Only as an idea. As you said, derive QSqlQueryModel or similar, the one you need.Then, you have to implement a protocol between client and server, so you can "proxy" calls between them.

A method might look like this ( as an example ) :


int MyClientModel::rowCount ( void ) const
{
// Call to TCP Server
return myRemoteServerManager.requestRowCount ( myID );
}


myRemoteServerManager is an object that wraps the implementation of interchange protocol.

myID is used to allow more than one connection for the same server with different models attached at the same time.

On server's side, you can derive also the same model, but simply adding the ID ( to search it easily ), and the TCP server must proxy the calls for client to the corrsponding server's model.

I don't know if it's a clear explanation or it's confusing... But the basic idea is : you have to wrap every call to the server's model.

wysota
13th July 2009, 09:58
You have to cache as much as possible. Otherwise it would become very slow.