|
457 | 457 | send-buffers_ (atom {:ws {} :ajax {}}) ; {<uid> [<buffered-evs> <#{ev-uuids}>]}
|
458 | 458 | connected-uids_ (atom {:ws #{} :ajax #{} :any #{}}) ; Public
|
459 | 459 |
|
460 |
| - upd-conn! |
| 460 | + upd-conn! ; Update client entry in conns_ |
461 | 461 | (fn
|
462 |
| - ([conn-type uid client-id] ; Update udt |
| 462 | + ([conn-type uid client-id] ; Update only udt |
463 | 463 | (swap-in! conns_ [conn-type uid client-id]
|
464 | 464 | (fn [?v]
|
465 |
| - (let [[?sch _udt] ?v |
| 465 | + (let [[?sch _?udt] ?v |
466 | 466 | new-udt (enc/now-udt)]
|
467 | 467 | (enc/swapped
|
468 | 468 | [?sch new-udt]
|
469 | 469 | {:init? (nil? ?v) :udt new-udt :?sch ?sch})))))
|
470 | 470 |
|
471 |
| - ([conn-type uid client-id new-?sch] ; Update sch + udt |
| 471 | + ([conn-type uid client-id old-?sch new-?sch] ; Update sch & udt |
472 | 472 | (swap-in! conns_ [conn-type uid client-id]
|
473 | 473 | (fn [?v]
|
474 |
| - (let [new-udt (enc/now-udt)] |
| 474 | + (let [[?sch _?udt] ?v |
| 475 | + new-udt (enc/now-udt) |
| 476 | + new-?sch |
| 477 | + (if (or (= old-?sch :any) (identical? old-?sch ?sch)) |
| 478 | + new-?sch ; CAS successful, Ref. #417 |
| 479 | + ?sch)] |
| 480 | + |
475 | 481 | (enc/swapped
|
476 | 482 | [new-?sch new-udt]
|
477 | 483 | {:init? (nil? ?v) :udt new-udt :?sch new-?sch}))))))
|
|
708 | 714 | params (get ring-req :params)
|
709 | 715 | client-id (get params :client-id)
|
710 | 716 | uid (user-id-fn ring-req client-id)
|
| 717 | + ;; ?ws-key (get-in ring-req [:headers "sec-websocket-key"]) |
711 | 718 |
|
712 | 719 | receive-event-msg! ; Partial
|
713 | 720 | (fn self
|
|
748 | 755 |
|
749 | 756 | ;; WebSocket handshake
|
750 | 757 | (let [_ (tracef "New WebSocket channel: %s (%s)" uid sch-uuid)
|
751 |
| - updated-conn (upd-conn! :ws uid client-id server-ch) |
| 758 | + updated-conn (upd-conn! :ws uid client-id :any server-ch) |
752 | 759 | udt-open (:udt updated-conn)]
|
753 | 760 |
|
754 | 761 | (when (connect-uid! :ws uid)
|
|
774 | 781 |
|
775 | 782 | ;; Ajax handshake/poll
|
776 | 783 | (let [_ (tracef "New Ajax handshake/poll: %s (%s)" uid sch-uuid)
|
777 |
| - updated-conn (upd-conn! :ajax uid client-id server-ch) |
| 784 | + updated-conn (upd-conn! :ajax uid client-id :any server-ch) |
778 | 785 | udt-open (:udt updated-conn)
|
779 | 786 | handshake? (or (:init? updated-conn) (:handshake? params))]
|
780 | 787 |
|
|
814 | 821 | (if websocket? "WebSocket" "Ajax")
|
815 | 822 | uid sch-uuid)
|
816 | 823 |
|
817 |
| - updated-conn (upd-conn! conn-type uid client-id nil) |
| 824 | + updated-conn (upd-conn! conn-type uid client-id server-ch nil) |
818 | 825 | udt-close (:udt updated-conn)]
|
819 | 826 |
|
820 | 827 | ;; Allow some time for possible reconnects (repoll,
|
|
0 commit comments