Skip to content

Commit

Permalink
Readme and Documentation has been updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
takielias committed Nov 17, 2019
1 parent 18dde4d commit 740c016
Show file tree
Hide file tree
Showing 3 changed files with 483 additions and 475 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]

# CodeIgniter WebSocket Library
CodeIgniter library realtime communication by using Websocket technology and Ratchet ([Socketo.me](http://socketo.me) & [ratchet_client](https://github.com/romainrg/ratchet_client))
CodeIgniter WebSocket library. It allows you to make powerfull realtime applications by using Ratchet ([Socketo.me](http://socketo.me) & [ratchet_client](https://github.com/romainrg/ratchet_client)) Websocket technology.

If you Face any problem you may check CodeIgniter WebSocket Example https://github.com/takielias/codeigniter-websocket-example

Expand Down Expand Up @@ -119,4 +122,11 @@ Be free to open an issue or send pull request
## Support on Beerpay
Hey dude! Help me out for a couple of :beers:!

[![Beerpay](https://beerpay.io/takielias/codeigniter-websocket/badge.svg?style=beer-square)](https://beerpay.io/takielias/codeigniter-websocket) [![Beerpay](https://beerpay.io/takielias/codeigniter-websocket/make-wish.svg?style=flat-square)](https://beerpay.io/takielias/codeigniter-websocket?focus=wish)
[![Beerpay](https://beerpay.io/takielias/codeigniter-websocket/badge.svg?style=beer-square)](https://beerpay.io/takielias/codeigniter-websocket) [![Beerpay](https://beerpay.io/takielias/codeigniter-websocket/make-wish.svg?style=flat-square)](https://beerpay.io/takielias/codeigniter-websocket?focus=wish)

[ico-version]: https://img.shields.io/packagist/v/takielias/codeigniter-websocket.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/takielias/codeigniter-websocket.svg?style=flat-square

[link-packagist]: https://packagist.org/packages/takielias/codeigniter-websocket
[link-downloads]: https://packagist.org/packages/takielias/codeigniter-websocket
[link-author]: https://github.com/takielias
92 changes: 46 additions & 46 deletions helpers/codeigniter_websocket_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,67 @@
* Date: 04/05/2019
* Time: 09:04 PM
*/
defined('BASEPATH') or exit('No direct script access allowed');

/**
* Inspired By
* Ratchet Websocket Library: helper file
* @author Romain GALLIEN <romaingallien.rg@gmail.com>
*/

defined('BASEPATH') or exit('No direct script access allowed');

if (!function_exists('valid_json')) {

/**
* Check JSON validity
* @method valid_json
* @author Romain GALLIEN <romaingallien.rg@gmail.com>
* @param mixed $var Variable to check
* @return bool
*/
function valid_json($var)
{
return (is_string($var)) && (is_array(json_decode($var,
true))) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
}
/**
* Check JSON validity
* @method valid_json
* @param mixed $var Variable to check
* @return bool
*/
function valid_json($var)
{
return (is_string($var)) && (is_array(json_decode($var,
true))) && (json_last_error() == JSON_ERROR_NONE) ? true : false;
}
}

if (!function_exists('valid_jwt')) {

/**
* Check JWT validity
* @method valid_jwt
* @param mixed $token Variable to check
* @return Object/false
*/
function valid_jwt($token)
{
return AUTHORIZATION::validateToken($token);
}
/**
* Check JWT validity
* @method valid_jwt
* @param mixed $token Variable to check
* @return Object/false
*/
function valid_jwt($token)
{
return AUTHORIZATION::validateToken($token);
}
}

/**
* Ratchet Websocket Library: helper file
* @author Romain GALLIEN <romaingallien.rg@gmail.com>
* Codeigniter Websocket Library: helper file
*/
if (!function_exists('output')) {

/**
* Output valid or invalid logs
* @method output
* @author Romain GALLIEN <romaingallien.rg@gmail.com>
* @param string $type Log type
* @param string $var String
* @return string
*/
function output($type = 'success', $output = null)
{
if ($type == 'success') {
echo "\033[32m" . $output . "\033[0m" . PHP_EOL;
} elseif ($type == 'error') {
echo "\033[31m" . $output . "\033[0m" . PHP_EOL;
} elseif ($type == 'fatal') {
echo "\033[31m" . $output . "\033[0m" . PHP_EOL;
exit(EXIT_ERROR);
} else {
echo $output . PHP_EOL;
}
}
/**
* Output valid or invalid logs
* @method output
* @param string $type Log type
* @param string $var String
* @return string
*/
function output($type = 'success', $output = null)
{
if ($type == 'success') {
echo "\033[32m" . $output . "\033[0m" . PHP_EOL;
} elseif ($type == 'error') {
echo "\033[31m" . $output . "\033[0m" . PHP_EOL;
} elseif ($type == 'fatal') {
echo "\033[31m" . $output . "\033[0m" . PHP_EOL;
exit(EXIT_ERROR);
} else {
echo $output . PHP_EOL;
}
}
}

0 comments on commit 740c016

Please sign in to comment.