简体   繁体   中英

Versioning hubs in SignalR

Are there ability to have different versions of the same hub that is chosen based on version sent by JS client ?

Surely there must be some kind of recommended best-practice for handling hub evolution (adding methods, changing parameters in existing methods, removing operations, etc) when you don't necessarily have control over client versions.

public void MyHubMethod(MyRequestModel model)
{
    if (model.Version > 1)
    {
        // If Param2 == null ==> Error!
        // Do stuff with Param2
    }
    else
    {
        // Preserve the old behavior, where Param1 was used and Param2 was optional
        // Do stuff with Param1
        if (model.Param2 != null)
        {
            // Do stuff with Param2
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM