Skip to content

Commit

Permalink
Merge pull request #713 from Cysharp/feature/UsePrefixCCoreForUnity
Browse files Browse the repository at this point in the history
Use MAGICONION_ prefix for symbol
  • Loading branch information
mayuki authored Oct 31, 2023
2 parents 59890da + 092f566 commit 23ed00b
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ There are two ways to use the gRPC library in Unity:

Since the maintenance of the C-core based library has ended in the gRPC project, we recommend using [YetAnotherHttpHandler](https://github.com/Cysharp/YetAnotherHttpHandler) . Please refer to the [README of YetAnotherHttpHandler](https://github.com/Cysharp/YetAnotherHttpHandler) for installation instructions.
If you are using the C-core gRPC library, please define `USE_GRPC_CCORE` symbol in "Scripting Define Symbols".
If you are using the C-core gRPC library, please define `MAGICONION_USE_GRPC_CCORE` symbol in "Scripting Define Symbols".

### Install MessagePack for C#
MessagePack for C# is not included in MagicOnion package. You need to download and install separately.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;
using MagicOnion.Client;
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
using Grpc.Core;
#else
using Grpc.Net.Client;
Expand Down Expand Up @@ -35,7 +35,7 @@ static void RegisterResolvers()
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void OnRuntimeInitialize()
{
#if !USE_GRPC_CCORE
#if !MAGICONION_USE_GRPC_CCORE
// Use Grpc.Net.Client instead of C-core gRPC library.
GrpcChannelProviderHost.Initialize(
new GrpcNetClientGrpcChannelProvider(() => new GrpcChannelOptions()
Expand All @@ -46,7 +46,7 @@ public static void OnRuntimeInitialize()
}
}));
#endif
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
// Initialize gRPC channel provider when the application is loaded.
GrpcChannelProviderHost.Initialize(new DefaultGrpcChannelProvider(new GrpcCCoreChannelOptions(new[]
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
using Grpc.Core;
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
using Grpc.Core;
#else
using Grpc.Net.Client;
Expand All @@ -12,7 +12,7 @@ namespace MagicOnion.Unity
/// <summary>
/// Provide and manage gRPC channels for MagicOnion.
/// </summary>
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
public class DefaultGrpcChannelProvider : GrpcCCoreGrpcChannelProvider
{
public DefaultGrpcChannelProvider() : base() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#if MAGICONION_UNITASK_SUPPORT
using Cysharp.Threading.Tasks;
#endif
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
using Channel = Grpc.Core.Channel;
#else
using Grpc.Net.Client;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void DrawChannels()
{
using (new EditorGUILayout.HorizontalScope())
{
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
if (diagInfo.UnderlyingChannel is Channel grpcCCoreChannel)
{
EditorGUILayout.LabelField($"Channel: {channel.Id} ({channel.Target}; State={grpcCCoreChannel.State})", EditorStyles.boldLabel);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
using System;
using System.Collections.Generic;
using Grpc.Core;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
using System.Collections.Generic;
using Grpc.Core;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !USE_GRPC_CCORE
#if !MAGICONION_USE_GRPC_CCORE
using Grpc.Net.Client;

namespace MagicOnion.Unity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Cysharp.Threading.Tasks;
#endif
using Grpc.Core;
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
using Channel = Grpc.Core.Channel;
#else
using Grpc.Net.Client;
Expand Down Expand Up @@ -152,7 +152,7 @@ public async Task ConnectAsync(DateTime? deadline = null)
#endif
{
ThrowIfDisposed();
#if USE_GRPC_CCORE
#if MAGICONION_USE_GRPC_CCORE
if (_channel is Channel grpcCChannel)
{
await grpcCChannel.ConnectAsync(deadline);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !USE_GRPC_CCORE
#if !MAGICONION_USE_GRPC_CCORE
using System;
using System.Collections.Generic;
using Grpc.Net.Client;
Expand Down

0 comments on commit 23ed00b

Please sign in to comment.