Beispiel #1
0
 public long ClientKill(string ipport, long?clientid, ClientType?type, string username, string addr, Confirm?skipme) => Call("CLIENT"
                                                                                                                             .SubCommand("KILL")
                                                                                                                             .InputIf(!string.IsNullOrWhiteSpace(ipport), ipport)
                                                                                                                             .InputIf(clientid != null, "ID", clientid)
                                                                                                                             .InputIf(type != null, "TYPE", type)
                                                                                                                             .InputIf(!string.IsNullOrWhiteSpace(username), "USER", username)
                                                                                                                             .InputIf(!string.IsNullOrWhiteSpace(addr), "ADDR", addr)
                                                                                                                             .InputIf(skipme != null, "SKIPME", skipme), rt => rt.ThrowOrValue <long>());
Beispiel #2
0
 internal LinkerResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, TargetServiceBase targetService, AuthInfoBase authInfo, ClientType?clientType, string provisioningState, VNetSolution vNetSolution, SecretStore secretStore, string scope) : base(id, name, resourceType, systemData)
 {
     TargetService     = targetService;
     AuthInfo          = authInfo;
     ClientType        = clientType;
     ProvisioningState = provisioningState;
     VNetSolution      = vNetSolution;
     SecretStore       = secretStore;
     Scope             = scope;
 }
        public IEnumerable <ClientTypHeadCount> ClientCountByType(ClientType?clientType)
        {
            IEnumerable <Client> query = context.Clients;

            if (clientType.HasValue)
            {
                query = query.Where(x => x.ClientType == clientType.Value);
            }
            return(query.GroupBy(x => x.ClientType)
                   .Select(g => new ClientTypHeadCount()
            {
                ClientType = g.Key.Value,
                Count = g.Count(),
            }).ToList());
        }
        Message GetClientKillMessage(EndPoint endpoint, long?id, ClientType?clientType, bool skipMe, CommandFlags flags)
        {
            List <RedisValue> parts = new List <RedisValue>(9)
            {
                RedisLiterals.KILL
            };

            if (id != null)
            {
                parts.Add(RedisLiterals.ID);
                parts.Add(id.Value);
            }
            if (clientType != null)
            {
                parts.Add(RedisLiterals.TYPE);
                switch (clientType.Value)
                {
                case ClientType.Normal:
                    parts.Add(RedisLiterals.normal);
                    break;

                case ClientType.Slave:
                    parts.Add(RedisLiterals.slave);
                    break;

                case ClientType.PubSub:
                    parts.Add(RedisLiterals.pubsub);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(clientType));
                }
                parts.Add(id.Value);
            }
            if (endpoint != null)
            {
                parts.Add(RedisLiterals.ADDR);
                parts.Add((RedisValue)Format.ToString(endpoint));
            }
            if (!skipMe)
            {
                parts.Add(RedisLiterals.SKIPME);
                parts.Add(RedisLiterals.no);
            }
            return(Message.Create(-1, flags, RedisCommand.CLIENT, parts));
        }
Beispiel #5
0
 /// <summary>
 /// 广播所有客户端
 /// </summary>
 /// <param name="msg">内容</param>
 /// <param name="type">客户端类型  传:null发送全部客户端</param>
 public void SendAll(Record msg, ClientType?type)
 {
     if (type == null)
     {
         foreach (var c in Clients)
         {
             c.Value.SendData(msg);
         }
     }
     else
     {
         foreach (var c in Clients.Where(m => m.Value.ClientType == type))
         {
             c.Value.SendData(msg);
         }
     }
 }
Beispiel #6
0
        public IEmployeeClient GetClient(ClientType?clientType = null)
        {
            bool isProxyEnabled = _proxySettings?.Enabled ?? false;

            if (isProxyEnabled && clientType == ClientType.ManualBindings)
            {
                var binding         = _proxySettings.GetNetTcpBinding();
                var endpointAddress = _proxySettings.GetEndpointAddress();

                var client = new EmployeeClient(binding, endpointAddress);
                client.TrySetMaxItemsInObjectGraph(_proxySettings);

                return(client);
            }

            if (isProxyEnabled && clientType == ClientType.ChannelFactory)
            {
                return(new ManuallyConfiguredEmployeeClient(_channelFactory.Value, _logger));
            }

            // this does not work in netcore mode since this relies on automatic configuration
            return(new EmployeeClient());
        }
        public Task <long> ClientKillAsync(long?id = null, ClientType?clientType = null, EndPoint endpoint = null, bool skipMe = true, CommandFlags flags = CommandFlags.None)
        {
            var msg = GetClientKillMessage(endpoint, id, clientType, skipMe, flags);

            return(ExecuteAsync(msg, ResultProcessor.Int64));
        }
        public IViewComponentResult Invoke(ClientType?clientTypeName = null)
        {
            var result = clientRepository.ClientCountByType(clientTypeName);

            return(View(result));
        }
        public void Connect(
            string signalingUrl,
            ClientType clientType,
            string streamId,
            int videoWidth,
            int videoHeight,
            int videoBitrate,
            RenderTexture renderTexture)
        {
            try
            {
                sora = new Sora();

                this.clientType = clientType;

                var config = new Sora.Config
                {
                    SignalingUrl       = signalingUrl,
                    ChannelId          = streamId,
                    VideoWidth         = videoWidth,
                    VideoHeight        = videoHeight,
                    VideoBitrate       = videoBitrate,
                    AudioOnly          = false,
                    Multistream        = false,
                    Role               = clientType == ClientType.Publisher ? Sora.Role.Sendonly : Sora.Role.Recvonly,
                    CapturerType       = Sora.CapturerType.UnityRenderTexture,
                    UnityRenderTexture = renderTexture
                };

                sora.OnAddTrack = (trackId) =>
                {
                    this.trackId = trackId;
                    OnLogEvent.Invoke("OnAddTrack", $"trackId: {trackId}");
                };
                if (clientType == ClientType.Player)
                {
                    receiveTexture = renderTexture;

                    sora.OnRemoveTrack = (trackId) =>
                    {
                        this.trackId = 0;
                        OnLogEvent.Invoke("OnRemoveTrack", $"trackId: {trackId}");
                    };
                }
                sora.OnNotify = (msg) =>
                {
                    OnLogEvent.Invoke("OnNotify", $"\"{msg}\"");
                };

                var isSuccess = sora.Connect(config);

                if (isSuccess)
                {
                    OnOpen?.Invoke();
                    OnLogEvent.Invoke("Sora Connect", "success");
                    OnDataChannelOpen?.Invoke();
                }
                else
                {
                    OnErrorEvent.Invoke("sora connect error", "");
                }
            }
            catch (Exception ex)
            {
                OnErrorEvent.Invoke("OnError", ex.Message);
            }
        }
Beispiel #10
0
 public static Faker <SaveClientViewModel> GenerateSaveClient(string clientUri = null, ClientType?clientType = null,
                                                              string logoutUri = null)
 {
     return(new Faker <SaveClientViewModel>()
            .RuleFor(s => s.ClientId, f => f.Random.Guid().ToString())
            .RuleFor(s => s.ClientName, f => f.Internet.DomainName())
            .RuleFor(s => s.ClientUri, f => clientUri ?? f.Internet.Url())
            .RuleFor(s => s.LogoUri, f => f.Internet.Avatar())
            .RuleFor(s => s.LogoutUri, f => logoutUri ?? f.Internet.Url())
            .RuleFor(s => s.Description, f => f.Lorem.Word())
            .RuleFor(s => s.ClientType, f => clientType ?? f.PickRandom <ClientType>()));
 }
Beispiel #11
0
 public string ClientList(ClientType?type = null) => Call("CLIENT".SubCommand("LIST")
                                                          .InputIf(type != null, "TYPE", type), rt => rt.ThrowOrValue <string>());
Beispiel #12
0
 public static Task <long> ClientKillAsync(long?id            = null, ClientType?clientType = null, EndPoint endpoint = null, bool skipMe = true,
                                           CommandFlags flags = CommandFlags.None)
 {
     return(Server.ClientKillAsync(id, clientType, endpoint, skipMe, flags));
 }