Skip to content

✨ Improve WebSocket connections#186

Merged
GabrielePicco merged 9 commits intomainfrom
feat/improve-websocket-connections
Nov 12, 2023
Merged

✨ Improve WebSocket connections#186
GabrielePicco merged 9 commits intomainfrom
feat/improve-websocket-connections

Conversation

@GabrielePicco
Copy link
Copy Markdown
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