コード例 #1
0
ファイル: hybi_legacy.hpp プロジェクト: 12w21/rippled
    void prepare_close_frame(message::data_ptr msg,
                             close::status::value /*code*/,
                             const std::string& /*reason*/)
    {
        assert(msg);
        if (msg->get_prepared()) {
            return;
        }
        
        msg->set_header(std::string());
        
        struct Marker
        {
            Marker () { value.uc = 0xff; }
            union {
                char c;
                unsigned char uc;
            } value;
        };
        static Marker marker;

        std::string val;
        val.append(1,marker.value.c);
        val.append(1,0x00);
        msg->set_payload(val);
        
        msg->set_prepared(true);
    }
コード例 #2
0
ファイル: hybi_legacy.hpp プロジェクト: 12w21/rippled
    void prepare_frame(message::data_ptr msg) {
        assert(msg);
        if (msg->get_prepared()) {
            return;
        }
        
        msg->set_header(std::string(1,0x00));

        struct Marker
        {
            Marker ()
            {
                union
                {
                    char c;
                    unsigned char uc;
                } v;
                
                v.uc = 0xff;

                value = std::string (1, v.c);
            }

            std::string value;
        };
        static Marker marker;
        msg->append_payload(marker.value);
        
        msg->set_prepared(true);
    }
コード例 #3
0
ファイル: broadcast_handler.hpp プロジェクト: 12w21/rippled
 void on_message(connection_ptr connection,message::data_ptr msg) {
     wscmd::cmd command = wscmd::parse(msg->get_payload());
     
     std::cout << "msg: " << msg->get_payload() << std::endl;
     
     if (command.command == "ack") {
         handle_ack(connection,command);
     } else {
         broadcast_message(msg);
     }
 }
コード例 #4
0
 void prepare_frame(message::data_ptr msg) {
     assert(msg);
     if (msg->get_prepared()) {
         return;
     }
     
     msg->set_header(std::string(1,0x00));
     
     msg->append_payload(std::string(1,0xFF));
     
     msg->set_prepared(true);
 }
コード例 #5
0
 void prepare_close_frame(message::data_ptr msg,
                          close::status::value /*code*/,
                          const std::string& /*reason*/)
 {
     assert(msg);
     if (msg->get_prepared()) {
         return;
     }
     
     msg->set_header(std::string());
     
     std::string val;
     val.append(1,0xFF);
     val.append(1,0x00);
     msg->set_payload(val);
     
     msg->set_prepared(true);
 }
コード例 #6
0
ファイル: broadcast_handler.hpp プロジェクト: 12w21/rippled
 void broadcast_message(message::data_ptr msg) {
     std::string hash = md5_hash_hex(msg->get_payload());
     struct msg& new_msg(m_msgs[hash]);
     
     new_msg.id = m_nextid++;
     new_msg.hash = hash;
     new_msg.size = msg->get_payload().size();
     new_msg.time_sent = boost::posix_time::microsec_clock::local_time();
     new_msg.time = 0;
     
     typename std::set<connection_ptr>::iterator it;
     
     // broadcast to clients        
     for (it = m_connections.begin(); it != m_connections.end(); it++) {
         //(*it)->send(msg->get_payload(),(msg->get_opcode() == frame::opcode::BINARY));
         for (int i = 0; i < 10; i++) {
             (*it)->send(msg);
         }
         
     }
     new_msg.sent = m_connections.size()*10;
     new_msg.acked = 0;
 }