Welcome Guest, Not a member yet? Register   Sign In
how can i build websocket application using codeigniter
#11

(07-14-2017, 12:40 AM)dpentavia Wrote:
(09-18-2016, 11:50 PM)kishor10d Wrote: Hello everyone,
Here I try to create a websocket (PHP Ratchet) application integrated with CodeIgniter.
Please take a look, I think you find it useful.

https://github.com/kishor10d/CodeIgniter...-Websocket

Please visit the link and download the repository.

is this working without angular?

Yes, It works with jQuery. There are another files which contain the implementation using jQuery. Please check the ReadME.md.
Reply
#12

(09-18-2016, 11:50 PM)kishor10d Wrote: Hello everyone,
Here I try to create a websocket (PHP Ratchet) application integrated with CodeIgniter.
Please take a look, I think you find it useful.

https://github.com/kishor10d/CodeIgniter...-Websocket

Please visit the link and download the repository.

can we use this for our other purposes? like real time vehicle tracking or communication with android application?please help at [email protected]
Reply
#13

@Danish, Perhaps this might help you to get a prototype up and running quickly. I don't know where you are on android programming but i gave it up as a bad job (i'm too old). I needed to replace our alarm system rapid, like the day before it broke, and wasted far too much time trying to develop an android program as user interface. The solution, which works great 8-) was to use a few distributed arduinos as contact monitors which send/receive mqtt messages via the network to/from mosquitto running on a raspberry pi. The control panels are any number of tablets showing only a browser directed to a website on the raspberry which runs apache2, mosquitto configured for websockets and codeigniter. The webpage listens via paho-mqtt.js for mqtt messages and updates the open/closed status for the corresponding items on the page. Tap buttons on the page to activate/deactivate the alarm in an area. Development time: half-nothing, budget: zero, satisfaction: 100%
Reply
#14

[quote pid="2817" dateline="1419390137"]
Hi,

I am building REST API for one of my mobile APP. I am using PHP codeigniter for creating API. While a particular api call from mobile app, I need to connect to socket and write some message to socket variable.
For eg, When user likes other users profile, there is an api call from mobile app to send realtime notification. So realtime notification handling by using socket and push notification. So while API call, I need to connect to socket and need to send some value to socket. In case of mobile app, I am using react native and I can use nodejs, javascript, socket.io to send and receive message or count.
So how its possible.
It will be helpful, if someone can share some sample code.

Thanks
[/quote]
Reply
#15

(12-27-2014, 05:43 PM)sneakyimp Wrote: It's important to realize that HTTP requests are accomplished by making a socket connection. The basic idea is that a client (e.g., a web browser) opens a socket connection, usually on port 80 (usually port 443 for HTTPS), to a web server and then uses that socket connection to request data from the web server using the HTTP protocol. E.g., it might send a request "GET /path/to/file.html" over the socket and the web server would respond by coughing up the html document. Depending on server and client configuration and the connection details, the client may request more files like images, CSS, and JS files before closing the socket connection.

Now if you are clever, you'll realize that by the time CodeIgniter comes into this scenario, the connection has already been made by the client to the web server and the web server runs your codeigniter code in response to the request. Basically, the socket connection has already been made and its waiting for a response from CodeIgniter over the open connection.

Within CodeIgniter, you might be able to create a new socket using socket_create_listen but this socket will only last as long as your CodeIgniter script is running. Once your script ends, the socket it created is likely to be closed and cleaned up during the garbage collection process-- unless you find a way to fork off a separate process form your code igniter script. You probably wouldn't want to fork off a process from your CodeIgniter system that opens a listening socket in response to many visitors coming. You might want to do this for a script accessible to administrators only. This sort of action is similar to rebooting a mail server or web server or firing up some kind of persistent service.

Another possibility is that your server might try to open a socket connection to someone else. A client might connect and say "hey my ip is 12.34.56.78 I want you to connect on port 1234" and then your server could use socket_connect to try and connect to the client but this in practice won't really work all that often because most users will be behind a firewall or a wireless router or something which is not set up to accept incoming socket connections on arbitrary ports. It takes a bit of know-how to set up NAT on one's LAN and you typically need a fairly capable router.

CodeIgniter *could* be used as a way to start/restart/reload/halt some kind of socket server on your web server, and CodeIgniter *might* be used in the construction of a socket server, but it seems quite awkward to me. I wrote a socket server in PHP called FlashMOG some time ago but haven't updated it in years.
Thank you all! I was about to start a similar subject but thanks to the input of all of you I don't have to.
Reply
#16

(12-27-2014, 05:43 PM)sneakyimp Wrote: It's important to realize that HTTP requests are accomplished by making a socket connection. The basic idea is that a client (e.g., a web browser) opens a socket connection, usually on port 80 (usually port 443 for HTTPS), to a web server and then uses that socket connection to request data from the web server using the HTTP protocol. E.g., it might send a request "GET /path/to/file.html" over the socket and the web server would respond by coughing up the html document. Depending on server and client configuration and the connection details, the client may request more files like images, CSS, and JS files before closing the socket connection.

Now if you are clever, you'll realize that by the time CodeIgniter comes into this scenario, the connection has already been made by the client to the web server and the web server runs your codeigniter code in response to the request. Basically, the socket connection has already been made and its waiting for a response from CodeIgniter over the open connection.

Within CodeIgniter, you might be able to create a new socket using socket_create_listen but this socket will only last as long as your CodeIgniter script is running. Once your script ends, the socket it created is likely to be closed and cleaned up during the garbage collection process-- unless you find a way to fork off a separate process form your code igniter script. You probably wouldn't want to fork off a process from your CodeIgniter system that opens a listening socket in response to many visitors coming. You might want to do this for a script accessible to administrators only. This sort of action is similar to rebooting a mail server or web server or firing up some kind of persistent service.

Another possibility is that your server might try to open a socket connection to someone else. A client might connect and say "hey my ip is 12.34.56.78 I want you to connect on port 1234" and then your server could use socket_connect to try and connect to the client but this in practice won't really work all that often because most users will be behind a firewall or a wireless router or something which is not set up to accept incoming socket connections on arbitrary ports. It takes a bit of know-how to set up NAT on one's LAN and you typically need a fairly capable router.

CodeIgniter *could* be used as a way to start/restart/reload/halt some kind of socket server on your web server, and CodeIgniter *might* be used in the construction of a socket server, but it seems quite awkward to me. I wrote a socket server in PHP called FlashMOG some time ago but haven't updated it in years.

Is it compatible with angular?
Reply
#17

Alex Lancer has posted a video where he creates a chat app using Ratchet and CI4:

https://www.youtube.com/watch?v=9qIIjv17IgQ
Reply
#18

Hy, I am just replying because i want to follow up the conversation, have the same issue
Reply




Theme © iAndrew 2016 - Forum software by © MyBB