/// <summary> /// Sends a private message /// </summary> /// <param name="socket"></param> /// <param name="nickname"></param> /// <param name="rawMessage"></param> /// <param name="command"></param> /// <returns></returns> private async Task <string> SendPrivateMessageCommand(WebSocket socket, string nickname, string rawMessage, string[] command) { var result = ""; var targetUser = command[1]; rawMessage = rawMessage.Replace(command[0], string.Empty).Replace(command[1], string.Empty).Trim(); var targetSocket = _connectionManager.GetSocketByNickName(targetUser); if (targetSocket != null) { result = ServerMessageConstants.GetMessage(ServerMessageConstants.PRIVATE_MESSAGE, nickname, targetUser, rawMessage); await _socketHandler.SendMessageToOriginTargetClients(socket, targetSocket, result); } else { result = ServerMessageConstants.GetMessage(ServerMessageConstants.USER_NOT_FOUND, targetUser); await _socketHandler.SendMessage(socket, result); } return(result); }