Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

[updated]Small CLI Chat

Before we get into the code itself please note the following:
- I just started learning about JMS and Stomp
- I made it to learn more about JMS and Stomp
- I didn't spend much time to make it perfect, look nice or be fast

It requires ActiveMQ to work and it only works from CLI (terminal), but it does not require a database.

That being said, don't hate on me if the code is nasty.

I also commented the code so it's easier for beginners to understand what's going on.

Feel free to let me know what you think and if there is a way to make it better.
Image (underlined is user input):
Spoiler (Click to View)

Code:
Pastebin link: http://pastebin.com/bcQZvC7L


Taking Yani's advice I've decided to try to make it OOP.
This is what came out of that:
http://pastebin.com/8Dmia7nW
@Yani, care to get into more details? If you have time of course.
I made this while I was at work to make time go by faster, hence I didn't spend that much time thinking about the logical structure, just wanted to make it work pretty much.
About the $chosen variable, I know it wasn't necesary, it was just easier for me to work with it.
(Nov 11, 2016 11:56 AM)Yani Wrote:  There's lots of stuff that could have been better.

You also misunderstood when I said to use exit(), I meant that as soon as the command is found, you can exit, instead of putting the exit statement at the end of the code.

You should look into OOP and how classes work, as this could be much better as a class, where a function listens for commands, then sends the command to another function to handle it. You could also move your text displays to their own function. And OOP Variables would also be easier.

I could keep going on about why this and that would be better but I'd have to explain way too much.

OOP is something you should definitely try to pick up, it's really useful.

I re-made it. Updated the main thread with the pastebin link.
Also going to post it here if somebody missed it : http://pastebin.com/8Dmia7nW
Cool thanks, this looks interesting. Good share mate.
How would I go about using this on a website with shared hosting?
(Nov 28, 2016 12:53 AM)Hexurp Wrote:  How would I go about using this on a website with shared hosting?

If you have the ability to add services you need to add PHP Stomp.

And regarding ActiveMQ, I think you need to talk to them about it. I had some problems while trying to run ActiveMQ on my localhost, had to create a new user and change the owner permissions of ActiveMQ. I also had to install other dependencies with pecl. Unless you have sudo access to the server (which I doubt) you need to send a ticket asking them to install ActiveMQ for you or at least tell you how you should go about it.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by Autolog19Oct 19, 2020 03:12 AM 6 260 Oct 19, 2020 03:12 AM
Last Post: FLUFFERS
[PHP] by E V OOct 26, 2017 06:21 PM 2 173 Oct 26, 2017 06:21 PM
Last Post: SIM-1407431
[PHP] by HieroglyphiczFeb 12, 2016 10:45 PM 4 166 Feb 12, 2016 10:45 PM
Last Post: Hieroglyphicz