Cysharp / MagicOnion

Unified Realtime/API framework for .NET platform and Unity.
MIT License
3.68k stars 417 forks source link

Is it possible to log StreamingHub's input argument values? #782

Closed SeoKangHoon closed 1 week ago

SeoKangHoon commented 3 weeks ago

hello. There are some issues that could not be resolved while using the library.

public class GamingHub : StreamingHubBase<IGamingHub, IGamingHubReceiver>, IGamingHub
{
    public async ValueTask<Player[]> JoinAsync(string roomName, string userName, Vector3 position, Quaternion rotation)
    {

    }    
}

In the GamingHub example, I want to output the roomName, userName, position, and rotation values ​​used when calling the JoinAsync method through a filter. I also want to output the response value, but how can I get the desired result?

LB-AhmadFarahani commented 2 weeks ago

Create a constructor for your GamingHub class. Get ILogger from DI container. Use that to log stuff inside your hub. Check here for more info on using ILogger https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-8.0 I'm not sure what you mean by response values, but if you mean http response data, then you should be able to log those using a filter after awaiting next inside Invoke. You can add ILogger the same way I mentioned above to filters as well.