Skip to content
Browse files

fix indentation.

  • Loading branch information...
1 parent 53ebfbf commit d0e890be2ad6c5299e73bc0a66ab4dcc61795c48 @akrennmair committed Sep 1, 2012
Showing with 41 additions and 41 deletions.
  1. +14 −14 lib/m2pp.cpp
  2. +3 −3 lib/m2pp.hpp
  3. +1 −1 lib/m2pp_internal.hpp
  4. +23 −23 lib/utils.cpp
View
28 lib/m2pp.cpp
@@ -33,7 +33,7 @@ void connection::reply_http(const request& req, const std::string& response, uin
}
httpresp << "\r\n" << response;
- reply(req, httpresp.str());
+ reply(req, httpresp.str());
}
void connection::reply(const request& req, const std::string& response) {
@@ -51,21 +51,21 @@ void connection::reply_websocket(const request& req, const std::string& response
}
void connection::deliver(const std::string& uuid, const std::vector<std::string>& idents, const std::string& data) {
- assert(idents.size() <= MAX_IDENTS);
+ assert(idents.size() <= MAX_IDENTS);
std::ostringstream msg;
- msg << uuid << " ";
+ msg << uuid << " ";
- size_t idents_size(idents.size()-1); // initialize with size needed for spaces
- for (size_t i=0; i<idents.size(); i++) {
- idents_size += idents[i].size();
- }
+ size_t idents_size(idents.size()-1); // initialize with size needed for spaces
+ for (size_t i=0; i<idents.size(); i++) {
+ idents_size += idents[i].size();
+ }
msg << idents_size << ":";
- for (size_t i=0; i<idents.size(); i++) {
- msg << idents[i];
- if (i < idents.size()-1)
- msg << " ";
- }
- msg << ", " << data;
+ for (size_t i=0; i<idents.size(); i++) {
+ msg << idents[i];
+ if (i < idents.size()-1)
+ msg << " ";
+ }
+ msg << ", " << data;
std::string msg_str = msg.str();
zmq::message_t outmsg(msg_str.length());
@@ -74,7 +74,7 @@ void connection::deliver(const std::string& uuid, const std::vector<std::string>
}
void connection::deliver_websocket(const std::string& uuid, const std::vector<std::string>& idents, const std::string& data, char opcode, char rsvd) {
- deliver(uuid, idents, utils::websocket_header(data.size(), opcode, rsvd) + data);
+ deliver(uuid, idents, utils::websocket_header(data.size(), opcode, rsvd) + data);
}
request request::parse(zmq::message_t& msg) {
View
6 lib/m2pp.hpp
@@ -30,9 +30,9 @@ class connection {
request recv();
void reply(const request& req, const std::string& response);
void reply_http(const request& req, const std::string& response, uint16_t code = 200, const std::string& status = "OK", std::vector<header> hdrs = std::vector<header>());
- void reply_websocket(const request& req, const std::string& response, char opcode=1, char rsvd=0);
- void deliver(const std::string& uuid, const std::vector<std::string>& idents, const std::string& data);
- void deliver_websocket(const std::string& uuid, const std::vector<std::string>& idents, const std::string& data, char opcode=1, char rsvd=0);
+ void reply_websocket(const request& req, const std::string& response, char opcode=1, char rsvd=0);
+ void deliver(const std::string& uuid, const std::vector<std::string>& idents, const std::string& data);
+ void deliver_websocket(const std::string& uuid, const std::vector<std::string>& idents, const std::string& data, char opcode=1, char rsvd=0);
private:
zmq::context_t ctx;
std::string sender_id;
View
2 lib/m2pp_internal.hpp
@@ -8,7 +8,7 @@ namespace m2pp {
std::vector<std::string> split(const std::string& str, const std::string& sep, unsigned int count = 0);
std::string parse_netstring(const std::string& str, std::string& rest);
std::vector<header> parse_json(const std::string& jsondoc);
- std::string websocket_header(size_t data_length, char opcode=1, char rsvd=0);
+ std::string websocket_header(size_t data_length, char opcode=1, char rsvd=0);
}
View
46 lib/utils.cpp
@@ -59,30 +59,30 @@ std::vector<header> parse_json(const std::string& jsondoc) {
}
std::string websocket_header(size_t data_size, char opcode, char rsvd) {
- std::ostringstream header;
- header.put(0x80|opcode|rsvd<<4);
- char dummyLength;
- size_t realLength=data_size;
- if (realLength < 126) {
- dummyLength = static_cast<char>(realLength);
- } else if (realLength < 1<<16) {
- dummyLength = 126;
+ std::ostringstream header;
+ header.put(0x80|opcode|rsvd<<4);
+ char dummyLength;
+ size_t realLength=data_size;
+ if (realLength < 126) {
+ dummyLength = static_cast<char>(realLength);
+ } else if (realLength < 1<<16) {
+ dummyLength = 126;
} else {
- dummyLength = 127;
- }
- header.put(dummyLength);
- if (dummyLength == 127) {
- header.put(realLength >> 56 &0xff);
- header.put(realLength >> 48 &0xff);
- header.put(realLength >> 40 &0xff);
- header.put(realLength >> 32 &0xff);
- header.put(realLength >> 24 & 0xff);
- header.put(realLength >> 16 & 0xff);
- } if (dummyLength == 126 || dummyLength == 127) {
- header.put(realLength >> 8 & 0xff);
- header.put(realLength & 0xff);
- }
- return header.str();
+ dummyLength = 127;
+ }
+ header.put(dummyLength);
+ if (dummyLength == 127) {
+ header.put(realLength >> 56 &0xff);
+ header.put(realLength >> 48 &0xff);
+ header.put(realLength >> 40 &0xff);
+ header.put(realLength >> 32 &0xff);
+ header.put(realLength >> 24 & 0xff);
+ header.put(realLength >> 16 & 0xff);
+ } if (dummyLength == 126 || dummyLength == 127) {
+ header.put(realLength >> 8 & 0xff);
+ header.put(realLength & 0xff);
+ }
+ return header.str();
}
}

0 comments on commit d0e890b

Please sign in to comment.
Something went wrong with that request. Please try again.