public override void action() { var message = agent.receive(); if (message != null) { var content = message.getContent(); var sender = message.getSender(); var receivedMessage = JsonConvert.DeserializeObject <HeaderMessage>(content); var type = receivedMessage.Type; var instance = MessageDeserializer.GetMessageInstance(type, content); agent.Handle(instance, sender); } else { block(); } }