public static IExplicitBytesClient CreateClient(Binding binding, Guid uuid, string address)
        {
            var bindingInfo = EndpointMapper.WcfToRpc(address);

            bindingInfo.EndPoint = CanonizeEndpoint(bindingInfo);
            var client = new ExplicitBytesClient(uuid, bindingInfo);

            //NOTE: applying any authentication on local IPC greatly slows down start up of many simulatanious service
            bool skipAuthentication = binding.Authentication == RPC_C_AUTHN.RPC_C_AUTHN_NONE && bindingInfo.Protseq == RpcProtseq.ncalrpc;

            if (skipAuthentication)
            {
                client.AuthenticateAsNone();
            }
            else
            {
                client.AuthenticateAs(null, binding.Authentication == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                                  ? ExplicitBytesClient.Anonymous
                                                                  : ExplicitBytesClient.Self,
                                      binding.Authentication == RPC_C_AUTHN.RPC_C_AUTHN_NONE
                                                                  ? RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_NONE
                                                                  : RPC_C_AUTHN_LEVEL.RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                      binding.Authentication);
            }

            return(client);
        }
        public static IExplicitBytesServer CreateHost(Binding binding, string address, Guid uuid)
        {
            var    host            = new ExplicitBytesServer(uuid);
            var    endpointBinding = EndpointMapper.WcfToRpc(address);
            string endPoint        = CanonizeEndpoint(endpointBinding);

            host.AddProtocol(binding.ProtocolTransport, endPoint, binding.MaxConnections);
            host.AddAuthentication(binding.Authentication);
            return(host);
        }
Exemplo n.º 3
0
        private OperationContext SetupOperationConext(IRpcCallInfo call, MessageRequest request, Type contractType)
        {
            var operationContext = new OperationContext {
                SessionId = request.Session
            };

            if (request.Session != null)
            {
                if (_duplex)
                {
                    lock (_clients)
                    {
                        RpcCallbackChannelFactory channelFactory = null;
                        bool contains = _clients.TryGetValue(request.Session, out channelFactory);
                        if (!contains)
                        {
                            var contract = AttributesReader.GetServiceContract(contractType);
                            channelFactory = new RpcCallbackChannelFactory(_endpoint._binding,
                                                                           contract.CallbackContract, new Guid(request.Session),
                                                                           true);
                            _clients[request.Session] = channelFactory;
                        }
                        var callbackBindingInfo = EndpointMapper.WcfToRpc(_endpoint._address);
                        if (!call.IsClientLocal)
                        {
                            //BUG: callbacks accross network does not work
                            //callbackAddress.NetworkAddr =  call.ClientAddress
                        }

                        callbackBindingInfo.EndPoint += request.Session.Replace("-", "");
                        operationContext.SetGetter(_clients[request.Session], EndpointMapper.RpcToWcf(callbackBindingInfo));
                    }
                }
            }
            return(operationContext);
        }