WebSockets with codeigniter |
[eluser]kaos78414[/eluser]
So I've been reading about websockets and I'm very excited for the possibilities and for what lies ahead. However, I've been reading some tutorials and I'm not sure what the best way to implement websockets is (I would like to have this done in CodeIgniter) For instance, let's say I want to have a chat bar similar to that of Facebook, and I want to use WebSockets to do it. How would you best accomplish this? Here's a link to a sample usage of WebSockets is PHP: http://code.google.com/p/phpwebsocket/so...server.php Now, I'd like to know where code like this is best placed. Obviously we'd need to first run the connection, which could happen in a Controller function or as part of one, and then consistently check if the connection is still open possibly in a controller constructor before allowing the sending and/or receiving of data. I'm just experimenting with it for now so I'm not too worried about security. But would it be too much overhead to use the form_validation class to validate websockets input? Tell me how you would implement maybe a chat application in CodeIgniter using websockets. Any thoughts are appreciated! Thanks! ![]()
[eluser]jaykaneda[/eluser]
I've also been looking into integrating WebSockets into a CI project. I too found the phpwebsocket script and was trying to figure out how it could be integrated into CI. Just wondering if any progress was made here?
[eluser]Nicholas Bello[/eluser]
As an aside - I found a chat bar similar to facebook a while back but sadly it doesn't look like there has been any progress on it. Ajax IM Sockets are very exciting (and I still need to get a better grasp on them) but I'm not sure a bar like you want is best done by sockets in PHP, I would think that's a task better left to javascript.
[eluser]jaykaneda[/eluser]
I did manage to implement phpwebsocket as a CI controller, and got the example working, but it all seemed a bit fragile. WebSockets is definitively exciting, but I think I'll be going for an ajax type solution for my project.
[eluser]Vheissu[/eluser]
[quote author="jaykaneda" date="1312335750"]I did manage to implement phpwebsocket as a CI controller, and got the example working, but it all seemed a bit fragile. WebSockets is definitively exciting, but I think I'll be going for an ajax type solution for my project.[/quote] Any example code of how you achieved such a thing with Websockets you can share with us?
[eluser]OliverHR[/eluser]
A good and short example at: http://mylittlehacks.appspot.com/phpwebsocket
[eluser]jaykaneda[/eluser]
[quote author="Vheissu" date="1313486305"][quote author="jaykaneda" date="1312335750"]I did manage to implement phpwebsocket as a CI controller, and got the example working, but it all seemed a bit fragile. WebSockets is definitively exciting, but I think I'll be going for an ajax type solution for my project.[/quote] Any example code of how you achieved such a thing with Websockets you can share with us?[/quote] phpwebsocket contains websocket.class.php, and I just made this a CI controller Code: class WebSocket{ to... Code: class WebSocket extends CI_Controller{ It also contains a script server.php. I also implemented this as a controller Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Then I just put the client.html in my views directory, as client.php. And finally a client contrroller which points to it Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I changed a couple of lines of code, as outlined here, before I could get the example to work, using the steps on the project home page, and that's about it. http://code.google.com/p/phpwebsocket/is...tail?id=33 I didn't take it any further than this, let us know how you get on.
[eluser]Unknown[/eluser]
Hello, I have two questions: 1.-How do you start the server? Is it enough writing the url in the browser to start? For example: http://localhost/my-project/index.php/server 2.-I can't connect the client with the server. Firefox says "Can't establish a connection to the server at ws://localhost:12345/my-project/index.php/server Thanks |
Welcome Guest, Not a member yet? Register Sign In |