neel...@gmail.com
unread,Jan 30, 2014, 5:59:45 AM1/30/14You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hi All,
As we have called AsyncOpen() method to open the channel and get the data from the channel and added nsIStreamListener to that.
When the data is available then OnDataAvailable() callback will be called and we will read the data from the channel and mail thread continue to process as per the data available.
Below is the code.
class nsStreamListener : public nsIStreamListener
{
public:
NS_DECL_ISUPPORTS
//NS_DECL_NSISTREAMLISTENER
//NS_DECL_NSIREQUESTOBSERVER
nsresult OnStartRequest(nsIRequest *req, nsISupports *ctx)
{
printf ("######### START REQUEST #######\n");
}
nsresult OnStopRequest(nsIRequest*, nsISupports*, nsresult)
{
printf ("######### STOP REQUEST #######\n");
}
NS_IMETHOD OnDataAvailable(nsIRequest *request, nsISupports *contxt, nsIInputStream *input_stream, PRUint32 offset, PRUint32 count)
{
}
}
int main()
{
......
......
nsIStreamListener *listener;
listener = new nsStreamListener();
rv = channel->AsyncOpen(listener, nsnull);
if (NS_FAILED(rv))
{
wxLogError(_("Failed to open async: %x"), rv);
return NULL;
}
return 0;
}
Here we are able to get the data from the channel. but here the issue is out application exist and after that callback OnDataAvailable is getting called. So we are not able to get the data.
If we put sleep before "return 0" then also callback is getting called after the main application exits.
Can anyone tell me how OnDataAvailable() should call first and then main thread will continue ?
Thanks in Advance