Welcome Guest, Not a member yet? Register   Sign In
How to implement a chat application in Codeigniter site.
#1

[eluser]SaJu[/eluser]
Hi all,

Recently I have developed a site using Codeigniter framework and it was my first assessment in any framework.
Now I would like to integrate a chat application in the same site. Already I have tried to implement a chat application (looks like google chat) in the site(the code sample has downloaded from a free site and it was done with ajax, jquery and php). Unfortunately the result was fail.
The sample chat application has mainly four files like chat.php,chat.js,jquery.js and a css file. I have modified the chat.php to make it as a controller class, also corresponding changes are made to the chat.js file. After these changes, the application starts working but the result was just 40%.
There are problems in session and in jquery calls. The sample chat codes has storing values in php session and they were using multi dimensional array format for storing it. I have modified these things to support codeigniter.
Finally I have found that jquery post($.post(url,data,resul)) function calls are working fine and ajax($.ajax(url,returntype.....)) function calls does not.

Thanks in advance for your valuable advise,
#2

[eluser]devbro[/eluser]
here is my two cents assuming you know:
ajax
mysql
cron

here is the look:
1. create a table for list of chatters(should have last call,name)
2. create a table for each line of chat(should have chatter,text,time posted)
3. create controller and view for login to chat, chat, retrieve chat, cron
4. login to chat is easy (just make sure the name does not exists and add it once succeed
5. the chat window will ajax call retrieve chat controller once in a while and add the content to chat window (it sends the time of last message to reduce overhead)
6. if something is typed it is sent to chat controller to be added to database
7. cron job runs in given time lapse(2min?) cleans all messages that are 2 min old as well as users that did not connect to server for that amount of time too.

i can see a chat program in this manner. some coding is involved but should not be too hard to implement from scratch.
#3

[eluser]SaJu[/eluser]
Hi,
Thanks for the reply.
Anyway I am giving an url here to download my code samples. There are two zip files,
1) The original chat application code (downloaded from a site).
2) Whatever I have tried within the codeigniter to implement above chat application .
Can you please check it from your side. If I have made any mistakes please correct me.

URL: http://v4us.in/download/


Thanks in advance
#4

[eluser]devbro[/eluser]
the fact that there are $_POST and $_GET and $_SESSION is annoying. you also need to create a custom login page for your chat. i recommend that you rewrite most of the code to be compatible with CI coding style. If you want you can enable $_GET at the beginning and see if you can get it to work.




Theme © iAndrew 2016 - Forum software by © MyBB