Closed mayuki closed 5 months ago
what happened to IInMemoryStorage
IInMemoryStorage
will no longer be supported from the next version.
This is because MagicOnion itself is not suitable for storing application state, for example when handling multiple servers or when there is a need to separate logic.
Application developers can implement equivalent functionality using DI and ConcurrentDictionary, etc. as needed.
Thank you for clarification.
This PR migrates the implementation of StreamingHub's Group to a new library called Multicaster. This allows for controls of the Group to be executed within the Hub's methods or within any application logic.
Added APIs
Client Property
A property Client that returns the receiver for the currently connected client is added to
StreamingHubBase<THub, TReceiver>
. This eliminates the need to create a group for receiver invocations to a single client.Updated APIs
IGroup -> IGroup<T>
Group.AddAsync
inStreamingHubBase<THub, TReceiver>
now returns anIGroup<TReceiver>
.Changes to Broadcast Methods
StreamingHub.Broadcast*
andIGroup.CreateBroadcaster*
methods have been updated to new APIs viaIMulticastGroup
.Broadcast
->All
BroadcastToSelf
->Only
orSingle
or theClient
property of StreamingHubBroadcastExcept
->Except
BroadcastTo
->Only
orSingle
Changes to Types Specified in GroupConfigurationAttribute
Although GroupConfigurationAttribute can be used to select a group's implementation for each Hub, IHubGroupRepositoryFactory has been removed. Instead, a type for IMulticastGroupProvider must be specified.
Controlling Groups through Application Logic
By obtaining IMulticastGroupProvider through DI, you can manage the group's lifecycle and members within the application logic.
Groups created with
IMulticastGroupProvider
can broadcast to clients through the group by registering StreamingHub'sClient
property.While this provides flexible management of groups, be aware that the client registration and group lifecycle are no longer managed by MagicOnion, and manual management will be necessary.
Removed APIs
IInMemoryStorage
has been deleted.We thought it would be better if MagicOnion did not manage application state.
IInMemoryStorage
cannot synchronize state on multiple servers, and it is usual for the game logic to manage state.Application developers can implement a similar feature using DI and ConcurrentDictionary, etc.
Migration v6 -> v7
The following Shims can be imported into a project to migrate from v6 to v7 to maintain compatibility where existing APIs are used. You can import this Shim into your project and use
StreamingHubBaseCompat
instead ofStreamingHubBase
.https://gist.github.com/mayuki/974ab44d5464eefb821a5619209f7068