Webbased chat in php without using database or file

前端 未结 14 1007
失恋的感觉
失恋的感觉 2021-02-02 14:49

I am trying to implement a realtime chat application using PHP . Is it possible to do it without using a persistent data storage like database or file . Basically what I need is

相关标签:
14条回答
  • 2021-02-02 15:41

    You need to use some kind of storage as a buffer. It IS plausable not to use file or db (which also uses a file). You can try using php's shared memory functions, but I don't know any working solution so you'll have to do it from scratch.

    0 讨论(0)
  • 2021-02-02 15:42

    in short answer, you can't. the current HTTP/HTML implementation doesn't support the pushstate so the algorithm of your chat app should follow :

    1. A: sent message
    2. B,C,D: do while a new message has been sent get this message.

    so the receivers always have to make a new request and check if a new message has been sent. (AJAX Call or something similar ) so always there are a delay between the sent event and the receive event.

    • which means the data must be saved in something global, like db or file system.

    take a look for : http://today.java.net/article/2010/03/31/html5-server-push-technologies-part-1

    0 讨论(0)
提交回复
热议问题