AndrewM16921 Posted October 18, 2012 Share Posted October 18, 2012 (edited) I could have sword I clicked on "coding help" ...please move this. Hi, I'm quite new to php so bear with me I was wondering if it was possible to create a server-like php file that would essentially interact with multiple users and allow them to communicate back and forth between users. Essentially, a client-server like thing. Not sure how to explain it better... I guess I need some sort of static memory that many sessions can access. The only thing I can think of now is make a session on one script, then the other scripts send a curl request or something with that session id to make certain requests. I'm sure there's a better way of doing this. Any help would be appreciated, thanks. Edited October 18, 2012 by AndrewM16921 Quote Link to comment https://forums.phpfreaks.com/topic/269647-server-esque/ Share on other sites More sharing options...
Christian F. Posted October 18, 2012 Share Posted October 18, 2012 Do you want a AJAX-based chat client, or more of a public messenger system (also known as forums)? Also, this should be in "Application Design", not "Coding help". Quote Link to comment https://forums.phpfreaks.com/topic/269647-server-esque/#findComment-1386147 Share on other sites More sharing options...
AndrewM16921 Posted October 18, 2012 Author Share Posted October 18, 2012 I've made a basic bulletin board already, I was thinking more of a real-time chat client. Perhaps ajax is what I need to use? I don't have a whole lot of web design experience, only random little things I do in my spare time. So essentially, more js than php? Or both? Quote Link to comment https://forums.phpfreaks.com/topic/269647-server-esque/#findComment-1386167 Share on other sites More sharing options...
kicken Posted October 18, 2012 Share Posted October 18, 2012 Rather than go through the hassle of creating a server script you can just use something like memcached to store whatever shared data you need. For instance if you had the concept of "rooms" then you would store any messages or other data related to a given room in memcached under a unique identifier (such as the room's name). For anyone trying to view that room you would just access the data from memcached using the same identifier. If on the other hand you want to go through the hassle of making a script, you would create a PHP script that opens a listening socket on a given port and accepts connections. You'd then have your other scripts connect via a socket to that server-script to store/get messages or other information. Setting up a system like this can be a bit complicated to do properly so you'll need to invest some time into it and learning how to manage sockets and protocols. As far as displaying the messages to the end user you'd likely be using an ajax setup to poll the server for new messages every x seconds in the background. That or just set the page to auto-reload every x seconds. A background poll using ajax would be ideal from a user experience point of view, and would not be too hard when using a library such as jQuery. Quote Link to comment https://forums.phpfreaks.com/topic/269647-server-esque/#findComment-1386169 Share on other sites More sharing options...
AndrewM16921 Posted October 19, 2012 Author Share Posted October 19, 2012 Ok, thanks for the info. I'll look into all that stuff. Quote Link to comment https://forums.phpfreaks.com/topic/269647-server-esque/#findComment-1386374 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.