Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Improve WebSocket connections #186

Merged
merged 9 commits into from
Nov 12, 2023

Conversation

GabrielePicco
Copy link
Collaborator

@GabrielePicco GabrielePicco commented Oct 21, 2023

Improve WebSocket connections

Status Type ⚠️ Core Change Issue
Ready Feature/Bug No #182 #183 #184

Problem

See #182, #183 and #184

Solution

Issues described in #184 are due registering to accounts before the websockets connection is open.

Added an event OnWebSocketConnect which can be used to await ws connection and register to accounts afterward:

void Start(){
    Web3.OnWebSocketConnect += OnWebSocketConnect;
}

private async void OnWebSocketConnect()
{
    await Web3.WsRpc.SubscribeAccountInfoAsync(new Account().PublicKey, 
        (sub, accountInfo) =>
    {
        Debug.Log($"AccountInfo: {accountInfo}");
    });
}

See: magicblock-labs/Solana.Unity-Core#47 for AutoReconnect and other improvements

Issues

Closes #184
Closes #182
Closes #183

@GabrielePicco GabrielePicco force-pushed the feat/improve-websocket-connections branch from 2791f8b to 94b2e00 Compare November 10, 2023 15:11
@GabrielePicco GabrielePicco merged commit 2d8eb8b into main Nov 12, 2023
@GabrielePicco GabrielePicco deleted the feat/improve-websocket-connections branch November 12, 2023 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant