elephant.io - https://github.com/Wisembly/elephant.io
1. elephantio.php - elephant.io 다운로드 src폴더 데이터에 대한 include 또는 require 파일 만들기
- <?php
- $___ELEPHANTIO_DIR = dirname(__FILE__);
- require $___ELEPHANTIO_DIR.'/Client.php';
- require $___ELEPHANTIO_DIR.'/AbstractPayload.php';
- require $___ELEPHANTIO_DIR.'/EngineInterface.php';
- require $___ELEPHANTIO_DIR.'/Engine/AbstractSocketIO.php';
- require $___ELEPHANTIO_DIR.'/Engine/SocketIO/Session.php';
- require $___ELEPHANTIO_DIR.'/Engine/SocketIO/Version1X.php';
- require $___ELEPHANTIO_DIR.'/Exception/MalformedUrlException.php';
- require $___ELEPHANTIO_DIR.'/Exception/ServerConnectionFailureException.php';
- require $___ELEPHANTIO_DIR.'/Exception/SocketException.php';
- require $___ELEPHANTIO_DIR.'/Exception/UnsupportedActionException.php';
- require $___ELEPHANTIO_DIR.'/Exception/UnsupportedTransportException.php';
- require $___ELEPHANTIO_DIR.'/Payload/Decoder.php';
- require $___ELEPHANTIO_DIR.'/Payload/Encoder.php';
- ?>
2. client.php
- <?php
- include 'lib/elephantio/elephantio.php';
- /*
- * Version1X arg2 Option : ['context'=>[], 'debug'=>false,'wait'=>100*1000,'timeout'=>ini_get("default_socket_timeout")];
- */
- $EIO = new ElephantIO\Client(
- new ElephantIO\Engine\SocketIO\Version1X('http://127.0.0.1:8001',['timeout'=>5])
- );
- $EIO->initialize();
- $EIO->emit('msgIn', array('data1','data2') );
- $EIO->close();
- ?>
3. nodejs server
- var io = require('socket.io').listen(8001);
- io.sockets.on('connection', function (socket){
- socket.on('msgIn',function(msg){
- console.log('Msg In : ',msg);
- });
- socket.on('disconnect', function(){
- console.log('NOT USER DISCONNECT : ', socket.id);
- });
- });
- /*
- * debug
- * Msg In : [ 'data1', 'data2' ]
- * NOT USER DISCONNECT : NPmXDQpuVM9OFYl0AAAA
- */