Example #1
0
        private void SendToChannel(MessageResponse response)
        {
            var connections = from cu in dc.ChannelUsers
                              join conn in dc.Connections on cu.UserId equals conn.CreatedUserId
                              where cu.ChannelId == response.Channel.Id
                              select conn;

            string currentUserId = GetCurrentUser().Id;

            if (response.Origin == MessageIndividual.User ||
                response.Command == MessageCommand.UserTypingStart ||
                response.Command == MessageCommand.UserTypingEnd)
            {
                connections = connections.Where(x => x.CreatedUserId != currentUserId);
            }

            connections.ToList().ForEach(connection =>
            {
                response.Sender = GetCurrentUser();
                response.Time   = DateTime.UtcNow;
                Clients.Client(connection.Id).SendAsync("received", response);
            });
        }
Example #2
0
 public static void Log(ReturnCode returnCode, string errorMessage)
 {
     Logs         = new MessageResponse(returnCode, errorMessage);
     LogsNonEmpty = false;
 }