|
240 | 240 |
|
241 | 241 | [clj ?cb-uuid])) |
242 | 242 |
|
243 | | -(def ^:dynamic *write-legacy-pack-format?* |
244 | | - "Advanced option, most users can ignore this var. Only necessary |
245 | | - for those that want to use Sente < v1.18 with a non-standard |
246 | | - IPacker that deals with non-string payloads. |
247 | | -
|
248 | | - Details: |
249 | | - Sente uses a private message format as an implementation detail |
250 | | - for client<->server comms. |
251 | | -
|
252 | | - As part of [#398], this format is being updated to support |
253 | | - non-string (e.g. binary) payloads. |
254 | | -
|
255 | | - Unfortunately updating the format is non-trivial because: |
256 | | - 1. Both the client & server need to support the same format. |
257 | | - 2. Clients are often served as cached cl/js. |
258 | | -
|
259 | | - To help ease migration, the new pack format is being rolled out |
260 | | - in stages: |
261 | | -
|
262 | | - Sente <= v1.16: reads v1 format only |
263 | | - writes v1 format only |
264 | | -
|
265 | | - Sente v1.17: reads v1 and v2 formats |
266 | | - writes v1 and v2 formats (v1 default) |
267 | | -
|
268 | | - Sente v1.18: reads v1 and v2 formats |
269 | | - writes v1 and v2 formats (v2 default) <- Currently here |
270 | | -
|
271 | | - Sente >= v1.19: reads v2 format only |
272 | | - writes v2 format only |
273 | | -
|
274 | | - This var controls which format to use for writing. |
275 | | - Override default with `alter-var-root` or `binding`." |
276 | | - |
277 | | - false) |
278 | | - |
279 | 243 | (defn- pack "[clj ?cb-uuid]->packed" |
280 | 244 | ([packer clj ] (pack packer clj nil)) |
281 | 245 | ([packer clj ?cb-uuid] |
282 | | - (let [?cb-uuid (if (= ?cb-uuid :ajax-cb) 0 ?cb-uuid) |
283 | | - packed |
284 | | - (interfaces/pack packer |
285 | | - (if-some [cb-uuid ?cb-uuid] |
286 | | - [clj cb-uuid] |
287 | | - [clj ]))] |
288 | | - |
289 | | - (if *write-legacy-pack-format?* |
290 | | - (str "+" (have string? packed)) |
291 | | - (do packed))))) |
| 246 | + (let [?cb-uuid (if (= ?cb-uuid :ajax-cb) 0 ?cb-uuid)] |
| 247 | + (interfaces/pack packer |
| 248 | + (if-some [cb-uuid ?cb-uuid] |
| 249 | + [clj cb-uuid] |
| 250 | + [clj ]))))) |
292 | 251 |
|
293 | 252 | (comment |
294 | 253 | (unpack default-edn-packer |
295 | | - (binding [*write-legacy-pack-format?* true] |
296 | | - (pack default-edn-packer [:foo])))) |
| 254 | + (pack default-edn-packer [:foo]))) |
297 | 255 |
|
298 | 256 | (deftype EdnPacker [] |
299 | 257 | interfaces/IPacker |
|
0 commit comments