Code Monkey home page Code Monkey logo

codeigniter-ratchet-websocket's Introduction

CodeIgniter-Ratchet-Websocket

NOTICE : This project is NOT production ready.

NOTICE : This project is NO longer maintened.

This library contains the demo of commenting/posting realtime using CodeIgniter-Ratchet-Websocket with AngularJS as client-side javascript framwork.

There is no rocket science I have done to achieve this.

As you know the CodeIgniter Directory Structure

There is a folder called CI- -application -third_party -Realtime (I put here Ratchet PHP Websocket Library)

I put my code here and just call that code using Javascript websocket.

How to use :

  1. Download the code.

  2. You got a database script with name "realtime.sql", just import that script into your database named "realtime" (You may use your name but you have to change database name in CodeIgniter's database.php also.

  3. Put the downloaded code in your web root folder (www or htdocs... whatever it may be).

  4. Goto application/config/constants.php

Change the constant BROADCAST_URL and set it as IP of your own computer.

  1. Open Command Prompt Move towards your webroot folder. We are having our websocket code at following path in our project.
application/third_party/Realtime/bin/server.php

We have to run that server.php file from command prompt.

Just move to that folder by using "cd" command.

c:/>cd xampp\htdocs\ci-ratchet\application\third_party\Realtime\bin

Press enter.. Now you are in that directory specifically, just run following command.

c:\xampp\htdocs\ci-ratchet\application\third_party\Realtime\bin>php server.php

If its error free and noting is populated, then its supposed that you got the success to start the websocket server.

  1. Now run your ci-ratchet project in browser by hitting url.
http://localhost/ci-ratchet/

Once AngularJS initialize, you can see the Textbox, just start typing and press enter.... VOLLAAAAAAAAA

Its working

  1. Check it in another browser for realtime experience.

  2. It has some permission issues on shared hosting, so it will gives throw some error. Check issue @ ratchetphp/Ratchet#409

It will work for sure if you have same user for your VPS and shared hosting space.

What I used?

  1. CodeIgniter 3.x PHP Framework (https://www.codeigniter.com/)

  2. Ratchet - Websocket for PHP (http://socketo.me/) by Chris Boden(@boden_c)

  3. AngularJS - A superheroic Javascript MVW Framework by Google

Same functionality using jQuery? => Yes

I have added 3 new files in the same project for better understanding in.

application/controllers/jquery.php

application/views/jquery.php

assets/app/Connection2.js

URL : http://localhost/ci-ratchet/index.php/jquery

codeigniter-ratchet-websocket's People

Contributors

kishor10d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codeigniter-ratchet-websocket's Issues

How to run server.php on cpanel?

First of all Many thanks for making this demo script for helping others like me to understand how we can use sockets.
I want to know how to run server.php on CPANEL??
I am using shared Hosting. Will it work on shared hosting also.??

Connection Localhost

Hello,

I am having connection issue on localhost server i am using 8080 port and console is showing this error

WebSocket connection to 'ws://192.168.0.105:8080/' failed: Error during WebSocket handshake: Unexpected response code: 302

Thanks,

Connection Timeout when send message

Hi,
First of all thank you for this great work.
I have ran your code and it worked fine. I decided to websocket for my auction site.
I copied your thirdparty folder and connection2.js. I changed constant.php
I also ran server.php by going into directory
and running it from command shell by entering => php server.php
Everytime I try to send a message saying:

Connection2.js:7 WebSocket connection to 'ws://192.168.0.104:2000/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

Can you please take a look and tell me what am i doing wrong.

How to use this project to serve the specific-user chatting

I have a website that should serve a student communication in our university, I found that this project is like a chat room, How can I convert it to another form where student can chat with a specific user using their ID ?? I so grateful for every help

Error of BROADCAST_URL

when i try to run command php server.php got following error the value of
BROADCAST_URL is set to a localhost ip that is 127.0.0.1 .
socket

Messages retrieving Issue

Hello,

When i sent a message connectionMessage client side not working after refreshing sender page then its receiving real time on other computer.

Thanks,

WebSocket connection

Hi,
I have implemented your code but i am getting following error
WebSocket connection to 'ws://mydomain.com/' failed: Error during WebSocket handshake: Unexpected response code: 301

Server Side exampel

An example on creating the connection from the server would be a great addition

How to get Chat app into CI_Controller

hi there, very interesting project !

I was thinking if it could be possible to somehow make your Chat.php class extend from CI_Controller ?
This would make a huge difference in terms of writing the chat server logic, one could insert data in the database directly from the socket server (using CI models and querybuilder classes... , among other things).

I tried extending from My_Controller but off course the application needs to fully integrate with the framework, I'm a bit puzzled if and how this could be accomplished... There might be security issues and of course the use of the session class could cause some unexpected behaviour, but still I think this could be worth taking a look at...

Excuse me if my question is not clear, basically I would be able to do this :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;

class Chat extends MY_Controller implements MessageComponentInterface {

    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        // not used...
    }

    public function onOpen(ConnectionInterface $conn) {
    }

    public function onMessage(ConnectionInterface $from, $msg) {
    }

    public function onClose(ConnectionInterface $conn) {
    }

    public function onError(ConnectionInterface $conn, \Exception $e) {
    }

}

/* End of file Chat.php */
/* Location: ./application/controllers/Chat.php */```

Server.php problem in cpanel

I was able to run server.php in cpanel using cron, but i am getting this error

Fatal error: Uncaught exception 'React\Socket\ConnectionException' with message 'Could not bind to tcp://0.0.0.0:2000: Address already in use'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.