Skip to content

feat: add user stream Websocket into C++ SDK - #25

Merged
SebastianBoehler merged 8 commits into
SebastianBoehler:mainfrom
yluoc:user-channel-WS
Oct 3, 2026
Merged

SebastianBoehler merged 8 commits into
SebastianBoehler:mainfrom
yluoc:user-channel-WS

Conversation

@yluoc

@yluoc yluoc commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adding Polymarket V2 user stream WS to SDK, which includes header file, source file, cmakelists, examples, and testcases.

Verification

  • tests/test_user_stream.cpp
  • examples/user_stream_example.cpp

Notes

New functionality passes all testcases and the live run against Polymarket's real user-channel server.

@yluoc
yluoc marked this pull request as ready for review October 1, 2026 20:25
@yluoc

yluoc commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Hello Sebastian, I am interested in contributing to your Polymarket V2 C++ SDK. What I add so far is a user-stream websocket connection, it passes with real polymarket creds. Looking forward to hear from you. @SebastianBoehler

@SebastianBoehler

SebastianBoehler commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Hi Bill, thanks for reaching out by email and for opening this PR! Contributions are very welcome, and I appreciate you adding this one!

@SebastianBoehler

SebastianBoehler commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Thanks again for the contribution. I reviewed 868e9c1 and some additional local probes exposed lifecycle cases that I think we should address before merging:

  1. Reconciliation runs before the subscription is restored. In handle_stream_gap(), the callback runs synchronously. On reconnect, the transport invokes it before sending the authenticated subscription. A REST refresh inside that callback can therefore miss changes between the refresh and subscription activation. Polymarket does not replay missed events. Please arrange recovery so consumers reconcile after subscription restoration, while retaining immediate gap notification to invalidate stale state. A test should check that ordering.

  2. A connection timeout leaves the socket running but disables event delivery. connect() deactivates the stream without stopping the transport. With a delayed handshake, I reproduced connect() returning false, followed by is_connected() becoming true while a valid order event was silently dropped. Please stop the transport when returning failure and add a delayed-handshake regression test.

  3. Terminal authentication rejection does not end run(). The rejection handler disconnects the socket, but the blocking loop waits for stop(). I reproduced rejection with close code 1008 while run() remained blocked. I'd expect terminal rejection to end that loop. Please cover rejection both during run() and before entering it.

Two smaller points: please split the larger new files where practical; I aim for roughly 300 lines per file. Also, is there a supported producer for the additional topic/type/payload parsing path? If not, please keep the parser focused on the actual wire format.

Does this match what you observed in your live testing? If you intended different behavior, I'd like to hear your reasoning. Could you implement these changes and the regression tests? I can then review the update. My additional checks used local servers; I did not independently test real Polymarket credentials.

@yluoc

yluoc commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

@SebastianBoehler Thanks for replying, all issues you mentioned are fixed, I also split the gaint files smaller and remove the topic/payloaded path. All changes passes the testcases and pass against the real server. Let me know if there still exists any issues.

@yluoc

yluoc commented Oct 3, 2026 via email •

Copy link
Copy Markdown
Contributor Author

@SebastianBoehler
SebastianBoehler merged commit 18272c9 into SebastianBoehler:main Oct 3, 2026
4 checks passed
@yluoc
yluoc deleted the user-channel-WS branch October 3, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants