I'm developing a simple chat web application based on the MSN protocol. The server communicates with the MSN server through a file resource returned from fsockopen ()
. The client accesses the server via XMLHttpRequest
. The server initially logs in, and prints out the contact list (formatted in an HTML table) which the client receives through the responseText ()
of the XMLHttpRequest
object.
Here's the problem. The file resource that is responsible for communication with the MSN server must be kept alive in order for all chat related functions to work (creating conversations, keeping track of offline/online state changes, etc). However in order for the XMLHttpRequest
to complete, the PHP script must finish execution. Which means the client will get no response from the XMLHttpRequest
while the chat session is in progress.
Whats worse is a file resource cannot be serialized, meaning I cannot simply store the chat session in a $_SESSION []
placeholder.
So, my question is, is there any possible way for me to 'transfer' a file resource from one file to another?