示例#1
0
        public async Task SendMessage(string message)
        {
            var userId = NameUserIdProvider.GetUserId(Context);

            if (userId != null)
            {
                var command = Newtonsoft.Json.JsonConvert.DeserializeObject <AckArmCommand>(message);
                var meter   = new EnergyMeter(command.Meter.serialId, userId, TypeOfEnergyMeter.House, null, command.Meter.count, command.Meter.Switch);
                await repository.Update(meter);
            }
            // await Clients.Group(userId).SendAsync("ReceiveMessage", message);
        }
示例#2
0
 public async Task ErrorMessage(string message)
 {
     var userId = NameUserIdProvider.GetUserId(Context);
     await Clients.Group(userId).SendAsync("ErrorMessages", message);
 }
示例#3
0
 public async Task JoinGroup()
 {
     //Get userId
     var userId = NameUserIdProvider.GetUserId(Context);
     await Groups.AddToGroupAsync(Context.ConnectionId, userId);
 }