Exemple #1
0
        private void SendToClient <T>(T message, GameReponseKey action, string connectionId, bool isSucceed = true)
        {
            RepositoryResponse <T> result = new RepositoryResponse <T>()
            {
                IsSucceed   = isSucceed,
                Data        = message,
                ResponseKey = GetResponseKey(action)
            };

            Clients.Client(connectionId).SendAsync(receiveMethod, result);
        }
Exemple #2
0
        private void SendToAll <T>(T message, GameReponseKey action, bool isSucceed = true, bool isMyself = true)
        {
            RepositoryResponse <T> result = new RepositoryResponse <T>()
            {
                IsSucceed   = isSucceed,
                Data        = message,
                ResponseKey = GetResponseKey(action)
            };

            if (isMyself)
            {
                Clients.All.SendAsync(receiveMethod, result);
            }
            else
            {
                Clients.Others.SendAsync(receiveMethod, result);
            }
        }
Exemple #3
0
        private void SendToGroup <T>(T message, GameReponseKey action, string groupName, bool isMySelf = true)
        {
            if (!string.IsNullOrEmpty(groupName))
            {
                RepositoryResponse <T> result = new RepositoryResponse <T>()
                {
                    IsSucceed   = true,
                    Data        = message,
                    ResponseKey = GetResponseKey(action)
                };

                if (isMySelf)
                {
                    Clients.Group(groupName).SendAsync(receiveMethod, result);
                }
                else
                {
                    Clients.OthersInGroup(groupName).SendAsync(receiveMethod, result);
                }
            }
        }