| 152 | } |
| 153 | |
| 154 | void |
| 155 | SocketConnection::serialize(jalib::JBinarySerializer &o) |
| 156 | { |
| 157 | JSERIALIZE_ASSERT_POINT("SocketConnection"); |
| 158 | o&_sockDomain&_sockType&_sockProtocol &_peerType; |
| 159 | |
| 160 | JSERIALIZE_ASSERT_POINT("SocketOptions:"); |
| 161 | uint64_t numSockOpts = _sockOptions.size(); |
| 162 | o &numSockOpts; |
| 163 | if (o.isWriter()) { |
| 164 | // JTRACE("TCP Serialize ") (_type) (_id.conId()); |
| 165 | typedef map<int64_t, map<int64_t, jalib::JBuffer> >::iterator levelIterator; |
| 166 | typedef map<int64_t, jalib::JBuffer>::iterator optionIterator; |
| 167 | |
| 168 | uint64_t numLvl = _sockOptions.size(); |
| 169 | o &numLvl; |
| 170 | |
| 171 | for (levelIterator lvl = _sockOptions.begin(); |
| 172 | lvl != _sockOptions.end(); ++lvl) { |
| 173 | int64_t lvlVal = lvl->first; |
| 174 | uint64_t numOpts = lvl->second.size(); |
| 175 | |
| 176 | JSERIALIZE_ASSERT_POINT("Lvl"); |
| 177 | |
| 178 | o&lvlVal &numOpts; |
| 179 | |
| 180 | for (optionIterator opt = lvl->second.begin(); |
| 181 | opt != lvl->second.end(); ++opt) { |
| 182 | int64_t optType = opt->first; |
| 183 | jalib::JBuffer &buffer = opt->second; |
| 184 | int64_t bufLen = buffer.size(); |
| 185 | |
| 186 | JSERIALIZE_ASSERT_POINT("Opt"); |
| 187 | |
| 188 | o&optType &bufLen; |
| 189 | o.readOrWrite(buffer.buffer(), bufLen); |
| 190 | } |
| 191 | } |
| 192 | } else { |
| 193 | uint64_t numLvl = 0; |
| 194 | o &numLvl; |
| 195 | |
| 196 | while (numLvl-- > 0) { |
| 197 | int64_t lvlVal = -1; |
| 198 | int64_t numOpts = 0; |
| 199 | |
| 200 | JSERIALIZE_ASSERT_POINT("Lvl"); |
| 201 | |
| 202 | o&lvlVal &numOpts; |
| 203 | |
| 204 | while (numOpts-- > 0) { |
| 205 | int64_t optType = -1; |
| 206 | int64_t bufLen = -1; |
| 207 | |
| 208 | JSERIALIZE_ASSERT_POINT("Opt"); |
| 209 | |
| 210 | o&optType &bufLen; |
| 211 | |