• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

number of users per channel via pfc\'s response

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
6 posts • Page 1 of 1

Postby vlzvl » Sat Dec 17, 2011 2:44 pm

Hello and congrats for this work,
I know how to read the currently online users via:
Code: Select all
  $info  = new pfcInfo( md5(yada) );
  $users = $info->getOnlineNick(foo);
  $num_users = count($users);

but this gives me 2 options to get it dynamically:
1) via the old fashioned way of a second ajax (i will not do such a thing,
pfc is already a heavy resource for a free server)
2) via pfc's response class, somehow

So how can i instruct the pfc to call the above code the
time it constructs its response, so to return that little tiny
number (instead of a resource-waster second ajax)

I dont know if there's already such a feature (modifying
responses by PHP and handle them by javascript) or
where to look :)

thank you for a needed masterpiece
Last edited by vlzvl on Sat Dec 17, 2011 2:47 pm, edited 1 time in total.
vlzvl
New member
 
Posts: 9
Joined: Sat Dec 17, 2011 2:24 pm
Top

Postby re*s.t.a.r.s.*2 » Sat Dec 17, 2011 4:10 pm

HI,

If this information is going to be presented outside the chat, example (main site page) then you need a second ajax call, but if this is going to be in the chat page then it can be done in pfcclient.js and present it in any part of the chat page itself...

hope this helps..

regards.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby vlzvl » Sat Dec 17, 2011 7:51 pm

hello and thanx,
I understood the file pfcclient.js is reponsible for handling the 'responses'.

More of it, the function 'handleResponse(cmd,resp,param)' is responsible
for the 'frequent' chat updating (the 'update' command - is coming every X time,
check your 'refresh_delay')

The problem is that when 'cmd' comes as 'update' it doesnt holds any params
(in 'resp' or 'param' functions params)

Is there's a way to 'program' the 'update' command in PHP? So to call whatever
php code we want, then return it in our way (or pfc) and handling it via
'handleResponse' ?

tx for the help

EDIT:
i want to change part of the very same page (eg. a div), no bothering with other pages.

EDIT2:
I think i found the solution to this.
I just found the 'commands' list as PHPs in /src/commands.
I opened the one named 'update.class.php' and find that on
line 73 i can 'program' the JS for 'handleResponse'.
This one:
Code: Select all
$xml_reponse->script("pfc.handleResponse('update', 'ok', 'test');");

With this knowledge i can program whatever i want in
'update' command, including the one mentioned in first entry.
thank you for your help
Last edited by vlzvl on Sat Dec 17, 2011 8:05 pm, edited 1 time in total.
vlzvl
New member
 
Posts: 9
Joined: Sat Dec 17, 2011 2:24 pm
Top

Postby re*s.t.a.r.s.*2 » Sat Dec 17, 2011 8:21 pm

Hi,

You dont need to touch that object , if you only want to show how many people there are in the chat just gather the nick ID and count them, and place it somewhere in the chat container..

That if I understood your first question,

So how can i instruct the pfc to call the above code the
time it constructs its response, so to return that little tiny
number (instead of a resource-waster second ajax)

But is nice that found what you wanted to do..

regards.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby vlzvl » Sat Dec 17, 2011 9:01 pm

thank you,
I really didnt wanted to dig in there and deploy code that it will be ruined
when i update the next phpfreechat :)
But i didnt find any other way to do that in the -frequency- i wanted to do.
(eg. in every pfc's refreshing, to avoid second calls mainly)

"You dont need to touch that object , if you only want to show how many people there are in the chat just gather the nick ID and count them, and place it somewhere in the chat container.."

I understand that its too much for a single number (online users) but what if i wanted to execute big-time
operations? it would be really nice to do such a thing while's in pfc's ajax call.
About the counting you mentioned, yes im doing pretty much this thing, but every X seconds ('refresh_delay')
its refreshed.
If there's another way, i would be gladly following it, but for now it seems i just updated the default pfc's 'update'
command :)
How about implementing hooks? for example "hook_preupdate" to call your thingies instead of going down there?
Last edited by vlzvl on Sat Dec 17, 2011 9:02 pm, edited 1 time in total.
vlzvl
New member
 
Posts: 9
Joined: Sat Dec 17, 2011 2:24 pm
Top

Postby re*s.t.a.r.s.*2 » Sat Dec 17, 2011 9:22 pm

Hi,

Every time someone logs in , the nick ID get update in the same refresh rate...
So everything is update for everybody , you just need to find where the nickids are gathered and inject them in the part of container you wanna show them..

Thats why I said if this were to be outside the chat , then you would need to call with ajax the php you mentioned above..

ok regards.
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top


Post a reply
6 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 20 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
cron
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub