protected override ChannelCreator CreateChannelCreator(Type contract, DuplexClientModel clientModel, params object[] channelFactoryArgs) { var type = typeof(DuplexChannelFactory <>).MakeGenericType(new[] { contract }); var channelFactory = ChannelFactoryBuilder.CreateChannelFactory(type, clientModel, channelFactoryArgs); ConfigureChannelFactory(channelFactory); var methodInfo = type.GetMethod("CreateChannel", new Type[0]); return((ChannelCreator)Delegate.CreateDelegate(typeof(ChannelCreator), channelFactory, methodInfo)); }
protected override ChannelCreator CreateChannelCreator(Type contract, RestClientModel clientModel, IChannelBuilderScope scope, params object[] channelFactoryArgs) { var type = typeof(WebChannelFactory <>).MakeGenericType(new[] { contract }); var channelFactory = ChannelFactoryBuilder.CreateChannelFactory(type, clientModel, channelFactoryArgs); scope.ConfigureChannelFactory(channelFactory); var methodInfo = type.GetMethod("CreateChannel", Type.EmptyTypes); return((ChannelCreator)Delegate.CreateDelegate(typeof(ChannelCreator), channelFactory, methodInfo)); }
private IEnumerator ProcessConnectToServer() { WriteLine("Connect"); // Create channel and connect to gateway var channelFactory = ChannelFactoryBuilder.Build <DomainProtobufSerializer>( endPoint: new IPEndPoint(IPAddress.Loopback, 5000), createChannelLogger: () => LogManager.GetLogger("Channel")); channelFactory.Type = ChannelType.Tcp; var channel = channelFactory.Create(); var t0 = channel.ConnectAsync(); yield return(t0.WaitHandle); if (t0.Exception != null) { WriteLine("Connection Failed: " + t0.Exception.Message); yield break; } G.Channel = channel; // get user var user = G.Channel.CreateRef <UserRef>(); var t1 = user.GetId(); yield return(t1.WaitHandle); ShowResult(t1, "GetId()"); if (t1.Status != TaskStatus.RanToCompletion) { yield break; } _gameObserver = (GameObserver)G.Channel.CreateObserver <IGameObserver>(this, startPending: true); // enter game var t2 = user.EnterGame("Test", _gameObserver); yield return(t2.WaitHandle); ShowResult(t2, "EnterGame()"); if (t2.Status != TaskStatus.RanToCompletion) { G.Channel.RemoveObserver(_gameObserver); _gameObserver = null; yield break; } _gameClient = (GameClientRef)t2.Result.Item1; _zone = new ClientZone( ClientEntityFactory.Default, new ProtobufChannelToServerZoneOutbound { TypeTable = new TypeAliasTable(), TypeModel = new DomainProtobufSerializer(), OutboundChannel = this }); _zoneChannel = new ProtobufChannelToClientZoneInbound { TypeTable = new TypeAliasTable(), TypeModel = new DomainProtobufSerializer(), InboundClientZone = _zone }; _gameObserver.GetEventDispatcher().Pending = false; }