<?
include_once(_DIR_EXT.'/HTML/c_page_XML_AJAX.php') ;
class c_page_ajax extends c_page_XML_AJAX
{
    // ДОБАВЛЕНИЕ НОВОЙ ТЕМЫ

    function kanal_read()
    {   $result=ESMO_RUDA()->rabbit_kanal_read() ;
        if (_sizeof($result)) foreach($result as $res) $this->add_element('show_notife',$res,array('color'=>'green')) ;
        else                                          $this->add_element('show_notife','Cообщений нет',array('color'=>'red')) ;

	    /*include_once(_DIR_EXT.'/rabbit/i_rabbit.php') ;
        $a=new SimpleReceiver() ;
        $result=$a->read('rudaesmo','esmo.out.trip_points') ;

        if (_sizeof($result['mess'])) $this->add_element('show_notife','Получено '._sizeof($result['mess']).' сообщений',array('color'=>'green')) ;
        else                         $this->add_element('show_notife','Cообщений нет',array('color'=>'red')) ;
        //damp_array($result) ;
        //$this->add_element('show_modal_window','HTML',array('title'=>'rabbit kanal read','width'=>'800px;')) ;
        //
	    */
    }

    function resend_packet()
    {   $rec=execSQL_van('select *  from  log_rabbit where pkey='.$_POST['packet_id']) ;
	    if ($rec['uid'])
	    {   $fname_msg='rabbit_packet_'.$rec['uid'].'_msg.json' ;
            $fname_body='rabbit_packet_'.$rec['uid'].'_body.json' ;
            if (file_exists(_TEMP_DIR.$fname_msg)) $msg=json_decode(file_get_contents(_TEMP_DIR.$fname_msg),1) ;
            if (file_exists(_TEMP_DIR.$fname_body)) $body=json_decode(file_get_contents(_TEMP_DIR.$fname_body),1) ;
		    $data['props']=array('message_id'=>$rec['message_id'],'type'=>$rec['type']) ;
		    $data['mess']=$body ;
		    ?><strong>Входящий пакет</strong><?
		    damp_array($data,1,-1) ;
		    ?><strong>Ответ сервера ЭСМО Руда</strong><?
		    $result=ESMO_RUDA()->on_event_rabbit_packet_received($data) ;
		    damp_array($result,1,-1) ;
	    }




	    $this->add_element('show_modal_window','HTML',array('title'=>'Повторный прием пакета','width'=>'800px;')) ;
    }


}
