Morti's new home - and temporary housing...

  • 28 Replies
  • 9929 Views
*

DaveMorton

  • Trusty Member
  • ********
  • Replicant
  • *
  • 636
  • Safe, Reliable Insanity, Since 1961
    • Geek Cave Creations
Morti's new home - and temporary housing...
« on: August 09, 2010, 12:24:02 am »
Ever since I integrated Morti into my pChat chatroom script, I’ve noticed that several issues relating to performance have cropped up, along with other issues, as well. In an effort to correct these issues, I’m completely re-writing pChat from the ground up. In the interim, I’ve created a page to take the place of pchat, temporarily, where visitors can still chat with Morti. the address is the same (http://www.geekcavecreations.com/pChat/), and Morti still responds as always. Of course, the telescope command is inoperative with this new page, but that functionality will be continued and improved with pChat 2.0, as will some other features.

Along these lines, if there’s anyone here who is familiar with jQuery (the basis for the new page, along with all of the new enhancements) I would more than welcome any assistance offered. I’m still very much a novice when it comes to jQuery, though that’s slowly changing. :)
Comforting the Disturbed, Disturbing the Comfortable
Chat with Morti!
LinkedIn Profile
CAPTCHA4us

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #1 on: August 09, 2010, 12:49:46 pm »
Thanks for the heads up.  I have used jQuery but I don't know a lot about it, I've not actually done any programming with it. Funnily enough these past few weeks I have finally been learning javascript and I have been using the prototype library a little.  It was not nearly so hard as I thought it might be.  Some of it is very similar to PHP and it's not taking too much effort to figure out objects.  Been very interesting actually, anyway I will stop rambling and wish you luck with this.  ;D

Edit : actually my first javascript project has been a chat room....I'm just adding features to it at the moment.  I'd like to implement it here at some point.
« Last Edit: August 09, 2010, 01:34:25 pm by Freddy »

*

DaveMorton

  • Trusty Member
  • ********
  • Replicant
  • *
  • 636
  • Safe, Reliable Insanity, Since 1961
    • Geek Cave Creations
Re: Morti's new home - and temporary housing...
« Reply #2 on: August 09, 2010, 01:42:10 pm »
I'm finding that using jQuery to implement a chat room is a LOT easier than I had expected, and once I get the hang of the notation used for manipulating both the page elements and the AJAX queries, it should be rather easy to implement all of the features I already had programmed in before. Most of the link, image and text formatting, as well as the chat filters are all handled in the PHP portion of the script. It's less of a performance hit to process these things server-side. It's funny, but pChat started almost 10 years ago as a learning exercise in porting a PERL script over to PHP. Back then, however, it wasn't AJAX driven. It was a set of four different frames pages, each calling a different PHP script. And there was only text color formatting, with nothing else in the way of features. I think it's safe to say that pChat has evolved well past it's original design. :D
Comforting the Disturbed, Disturbing the Comfortable
Chat with Morti!
LinkedIn Profile
CAPTCHA4us

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #3 on: August 10, 2010, 02:13:11 pm »
My chat is AJAX driven too but I tried to put as much processing on the client side as possible to save this site from overworking.  Things like text colour and smilies are managed client side, I just send the raw messages to the client and do the data handling and formatting there.

I don't know how or even if this will work on the Ai Dreams site, I will just have to test it out and see if there is a performance drop for the site.

I'm trying to think of a name for my chat program... thought of 'Mercurius Chat'...also ChatCat....oh boy names..
« Last Edit: August 10, 2010, 02:27:28 pm by Freddy »

*

DaveMorton

  • Trusty Member
  • ********
  • Replicant
  • *
  • 636
  • Safe, Reliable Insanity, Since 1961
    • Geek Cave Creations
Re: Morti's new home - and temporary housing...
« Reply #4 on: August 10, 2010, 04:33:03 pm »
One thing to bear in mind is that, whether you have text that needs to be parsed (e.g. colors, font processing, etc.) or not, you still have data being sent to and from the server. The actions that cause the biggest performance hits are (in order of performance loss):

1.) network traffic (sending and receiving data)
2.) browser processing (JavaScript, mostly)
3.) server-side processing

With this in mind, if you're sending data to the server anyway, it's best to perform all of the text parsing there. PHP is anywhere from three to ten times faster than client-side processing, when given the same task. Besides, the task of processing color and font tags client-side is formidable, whereas in PHP, it's a cinch. trying to parse "[ color=red]red[ /color]" in JS? ACK!!!  ;D In PHP?
Code
$in  = str_replace('[ color=red]', '<span class="red">', $in);
$in  = str_replace('[ /color]', '</span>', $in);
Nothing simpler. :) (of course, the spaces in the color and span tags are for display purposes within this post, and need to be removed in actual code)

Also, rather than having your AJAX call perform a full page re-write every few seconds, you should send a small ajax request that looks to see if the page needs changing in the first place. If it does, then re-draw the page to reflect the changes. This is a HUGE bandwidth saver, and can be called every second, which will make the page seem to be more dynamic when there are changes available, rather than every 3-5 seconds the other way.
Comforting the Disturbed, Disturbing the Comfortable
Chat with Morti!
LinkedIn Profile
CAPTCHA4us

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #5 on: August 10, 2010, 04:40:11 pm »
Thanks for the tips.  Yes on the full page rewrite, I avoid that by polling the server every second to see if there are in fact any new messages, if it doesn't find anything then it doesn't update.

I'll consider moving colours etc over to PHP thanks :)

*

DaveMorton

  • Trusty Member
  • ********
  • Replicant
  • *
  • 636
  • Safe, Reliable Insanity, Since 1961
    • Geek Cave Creations
Re: Morti's new home - and temporary housing...
« Reply #6 on: August 10, 2010, 06:21:03 pm »
If you'd like, Freddy, I'm more than happy to share my code with you. But the current code right now should be used as a guide on how NOT to do things. :)
Comforting the Disturbed, Disturbing the Comfortable
Chat with Morti!
LinkedIn Profile
CAPTCHA4us

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #7 on: August 10, 2010, 07:00:53 pm »
Thanks for the offer but I am deliberately making it hard for myself so I learn as much as I can.  I find I remember it a lot better that way lol

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: Morti's new home - and temporary housing...
« Reply #8 on: August 10, 2010, 08:58:29 pm »
But Freddy...don't you recall all your friends telling you not to be so hard on yourself!

Ya can't have it both ways, mate! ;D
In the world of AI, it's the thought that counts!

*

DaveMorton

  • Trusty Member
  • ********
  • Replicant
  • *
  • 636
  • Safe, Reliable Insanity, Since 1961
    • Geek Cave Creations
Re: Morti's new home - and temporary housing...
« Reply #9 on: August 10, 2010, 10:07:33 pm »
No problems, Freddy. I'm the same way, at times. If you need anything, though, you know where to find me. :)
Comforting the Disturbed, Disturbing the Comfortable
Chat with Morti!
LinkedIn Profile
CAPTCHA4us

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #10 on: August 11, 2010, 12:32:47 pm »
Thanks.  I'm sure there will be something.  :)

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #11 on: August 11, 2010, 02:27:12 pm »
But Freddy...don't you recall all your friends telling you not to be so hard on yourself!

Ya can't have it both ways, mate! ;D
Oops hehe  :D

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #12 on: August 15, 2010, 02:33:09 pm »
Morti was chatting really well today  8)

One thing that came to me... after I said bye; I was going to copy the log, then realised it reads from bottom to top.  I thought I would suggest you reverse that, then the chat could be posted on forums etc.  Or...perhaps you could create a chat log in the background that the chatter can access and have it top to bottom... just a small thing..

I think I am going to implement a chatlog in my chat room, that will be plain HTML so that it can be saved but still have all the hyper-links in it.  I might do that today.

Keep up the good work  ;D

*

DaveMorton

  • Trusty Member
  • ********
  • Replicant
  • *
  • 636
  • Safe, Reliable Insanity, Since 1961
    • Geek Cave Creations
Re: Morti's new home - and temporary housing...
« Reply #13 on: August 16, 2010, 01:12:00 pm »
After trying the display both ways, I decided to have it show the newest at the top for two reasons:

1.) For chat conversations, this method seemed to me to feel more "natural".
2.) With the page being created/updated through AJAX, there's really no easy way to make long conversation logs that have a "top down" (newest response at the bottom) format show the correct position. In other words, every time the bot responds, you would have to scroll down, past a certain point in the conversation.

I'm working on a version that will place the most recent input and response in it's own div, just above the chat log. This way, the chat log can be viewed top down, yet the most recent will always be visible, without having to scroll. I should have it working within an hour, or so, and if I like it, I'll have it uploaded shortly after.
Comforting the Disturbed, Disturbing the Comfortable
Chat with Morti!
LinkedIn Profile
CAPTCHA4us

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6858
  • Mostly Harmless
Re: Morti's new home - and temporary housing...
« Reply #14 on: August 16, 2010, 01:45:18 pm »
Ah righto, I see your reasoning.  Having the chat log will be a nice touch :)

 


AI controlled F-16, for real!
by frankinstien (AI News )
Today at 01:04:11 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am
Nvidia Hype
by 8pla.net (AI News )
December 06, 2023, 10:04:52 pm
How will the OpenAI CEO being Fired affect ChatGPT?
by 8pla.net (AI News )
December 06, 2023, 09:54:25 pm
Independent AI sovereignties
by WriterOfMinds (AI News )
November 08, 2023, 04:51:21 am

Users Online

338 Guests, 1 User
Users active in past 15 minutes:
frankinstien
[Replicant]

Most Online Today: 361. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles