Esempio n. 1
0
 // TODO: to factor away
 binary_string_ptr prepare_frame(frame::opcode::value opcode,
                                 bool mask,
                                 const binary_string& payload)  {
     if (opcode != frame::opcode::TEXT) {
         // TODO: hybi_legacy doesn't allow non-text frames.
         throw;
     }
     
     // TODO: mask = ignore?
     
     // TODO: utf8 validation on payload.
     
     binary_string_ptr response(new binary_string(payload.size()+2));
     
     (*response)[0] = 0x00;
     std::copy(payload.begin(),payload.end(),response->begin()+1);
     (*response)[response->size()-1] = 0xFF;
     
     return response;
 }