Jump to content

Recommended Posts

I could have sword I clicked on "coding help" ...please move this.

 

Hi, I'm quite new to php so bear with me :P

 

 

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 by AndrewM16921
Link to comment
https://forums.phpfreaks.com/topic/269647-server-esque/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/269647-server-esque/#findComment-1386167
Share on other sites

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.

 

Link to comment
https://forums.phpfreaks.com/topic/269647-server-esque/#findComment-1386169
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.