Archived

This forum has been archived. Please start a new discussion on GitHub.

File transfer and threading.

Hello! i'm currently working on implementing a servlet that let's me take files from him. I need to be able to send the file from the servlet in a second thread, because if two clients ask me for differents files i want to be able to procces incoming messages while uploading the file. Will this interface suit my need? What else should i take in mind when implementing this?

Thank you!
sequence<byte> ByteSeq;
    
interface FileProvider
{
   // To read a buffer from a provider file
   ["ami"] nonmutating ByteSeq getFile(string path, int pos, int num);
}

Comments

  • marc
    marc Florida
    Yes, I think this interface will work fine. What concerns do you exactly have?
  • In fact having read the documentation again, i think waht i need is amd... but i'm worry about don't getting the right meaning for each term (amd, ami).

    What i need is a responsible GUI while i transfer file from my servlet, and i need to be able to respond to other method calls while transfering the file too.

    My application scheme is like this:
    module Q4MusicServer
    {
        sequence <Q4MusicClient::Mp3Client*> ClientList;
        
        interface Mp3Server
        {
            // Add a client to the queue
    	idempotent void RegisterClient(Q4MusicClient::Mp3Client* c, out bool bSuccess);
    	    
    	// Remove a client from the queue
    	idempotent void UnregisterClient(Q4MusicClient::Mp3Client* c);
            
            // Send a message to a client.
            nonmutating SendMessage(string message);
    	};
    };
    

    This "music server" is on the only machine that have speakers on my office, so a number of clients is going to register to this server to request his music is played. The server register all clients and then, one by one, request the files from every client. The client interface is like is:
    module Q4MusicClient
    {
        sequence<byte> ByteSeq;
        
    	interface Mp3Client
    	{
                nonmutating bool HasFile(string fileName);
            
    	    ["ami"] nonmutating ByteSeq getFile(string path, int pos, int num);
            
                // Gets the name of the mp3 that the client want to play
                nonmutating string GetCurrentMp3Name();
    
                nonmutating SendMessage(string message);
           
                // if the server is shut-down, first it tries to disconnect the clients
                idempotent void Disconnect();
    	};
    };
    

    In my server the mp3 player runs on his own thread, and i can set a callback to the mp3 filereader, so i'm not concerned about blocking on the server. The file read callback, in fact, should wait the response of the client method getFile, similar to what happen when you read a file from the disk

    In the client, in the other side, i need to procces the response to the getFile and, maybe, at the same time, respond to other methods (like server sending me a message using SendMessage), and i need to keep the GUI responsive too. For this reasons, i think i should use AMD on the Mp3Client instead of AMI. What do you think???

    Thank you very much!
  • marc
    marc Florida
    I'm afraid your questions go beyond the free support we can offer here in these forums. In essence, you are asking for help with the design of your particular application. We can offer this as consulting services to your company. If you are interested, please contact us at info@zeroc.com.