private static StreamingHubClientBase <TStreamingHub, TReceiver> CreateClient <TStreamingHub, TReceiver>(CallInvoker callInvoker, TReceiver receiver, string host, CallOptions option, MessagePackSerializerOptions serializerOptions, IMagicOnionClientLogger logger) where TStreamingHub : IStreamingHub <TStreamingHub, TReceiver> { var ctor = StreamingHubClientRegistry <TStreamingHub, TReceiver> .consturtor; StreamingHubClientBase <TStreamingHub, TReceiver> client = null; if (ctor == null) { #if ((ENABLE_IL2CPP && !UNITY_EDITOR) || NET_STANDARD_2_0) throw new InvalidOperationException("Does not registered client factory, dynamic code generation is not supported on IL2CPP. Please use code generator(moc)."); #else var type = StreamingHubClientBuilder <TStreamingHub, TReceiver> .ClientType; client = (StreamingHubClientBase <TStreamingHub, TReceiver>)Activator.CreateInstance(type, new object[] { callInvoker, host, option, serializerOptions, logger }); #endif } else { client = (StreamingHubClientBase <TStreamingHub, TReceiver>)(object) ctor(callInvoker, receiver, host, option, serializerOptions, logger); } return(client); }
public static TStreamingHub Connect <TStreamingHub, TReceiver>(CallInvoker callInvoker, TReceiver receiver, string host = null, CallOptions option = default(CallOptions), IFormatterResolver resolver = null, ILogger logger = null) where TStreamingHub : IStreamingHub <TStreamingHub, TReceiver> { var ctor = StreamingHubClientRegistry <TStreamingHub, TReceiver> .consturtor; StreamingHubClientBase <TStreamingHub, TReceiver> client = null; if (ctor == null) { #if ((ENABLE_IL2CPP && !UNITY_EDITOR) || NET_STANDARD_2_0) throw new InvalidOperationException("Does not registered client factory, dynamic code generation is not supported on IL2CPP. Please use code generator(moc)."); #else var type = StreamingHubClientBuilder <TStreamingHub, TReceiver> .ClientType; client = (StreamingHubClientBase <TStreamingHub, TReceiver>)Activator.CreateInstance(type, new object[] { callInvoker, host, option, resolver, logger }); #endif } else { client = (StreamingHubClientBase <TStreamingHub, TReceiver>)(object) ctor(callInvoker, receiver, host, option, resolver, logger); } client.__ConnectAndSubscribe(receiver); return((TStreamingHub)(object)client); }