angular.module('ruvidding.messages', []).factory('MessageFactory', ['$injector', 'Logger', function ($injector, Logger) {
  var logger = new Logger('MessageFactory');
  var injector = $injector;
  return function (data) {
    if (data.messageType.match(/Message$/)) {
      return new (injector.get(data.messageType))(data);
    } else {
      logger.error('Unable to work with ' + data.messageType);
    }
  };
}
])
.factory('IceCandidateMessage', ['PeerConnector', function (PeerConnector) {
  var IceCandidateMessage = function (data) {
    this.data = data;
    this.to = data.to;
    this.from = data.from;
  };
  IceCandidateMessage.prototype.exec = function () {
    PeerConnector.addIceCandidateTo(this.from, this.data);
  };
  return IceCandidateMessage;

}])
.factory('ProclamationMessage', ['PeerConnector', function (PeerConnector) {
  var ProclamationMessage = function (data) {
    this.data = data;
    this.to = data.to;
    this.from = data.from;
  };
  ProclamationMessage.prototype.exec = function () {
    PeerConnector.createOffer(this.from, {});
  };
  return ProclamationMessage;
}])
.factory('AnswerSessionDescriptionMessage', ['PeerConnector', function (PeerConnector) {
  var AnswerSessionDescriptionMessage = function (data) {
    this.data = data;
    this.to = data.to;
    this.from = data.from;
  };
  AnswerSessionDescriptionMessage.prototype.exec = function () {
    PeerConnector.connect(this.from, this.data.description);
  };
  return AnswerSessionDescriptionMessage;
}])
.factory('OfferSessionDescriptionMessage', ['PeerConnector', function (PeerConnector) {
  var OfferSessionDescriptionMessage = function (data) {
    this.data = data;
    this.to = data.to;
    this.from = data.from;
  };
  OfferSessionDescriptionMessage.prototype.exec = function () {
    PeerConnector.createAnswer(this.from, this.data.description, {});
  };
  return OfferSessionDescriptionMessage;
}]);

@@ -80,24 +80,27 @@
 , 'Logger', 
+%0A  
 function ($i
@@ -114,24 +114,26 @@
 , Logger) %7B%0A
+  
   var logger
@@ -167,16 +167,18 @@
 ry');%0A  
+ 
+ 
 var inje
@@ -195,16 +195,18 @@
 jector;%0A
+  
   return
@@ -220,24 +220,26 @@
 on (data) %7B%0A
+  
     if (data
@@ -274,24 +274,26 @@
 /)) %7B%0A      
+  
 return new (
@@ -335,16 +335,18 @@
 a);%0A    
+  
 %7D else %7B
@@ -352,16 +352,18 @@
 %7B%0A      
+ 
+ 
 logger.e
@@ -419,17 +419,166 @@
     
-%7D%0A  %7D;%0A%7D%0A
+  %7D%0A    %7D;%0A  %7D%0A%5D)%0A.factory('Message', %5Bfunction () %7B%0A  return function (data) %7B%0A    this.data = data;%0A    this.to = data.to;%0A    this.from = data.from;%0A  %7D;%0A%7D
 %5D)%0A.
@@ -707,74 +707,32 @@
     
-this.data = data;%0A    this.to = data.to;%0A    this.from = data.from
+Message.call(this, data)
 ;%0A  
@@ -881,17 +881,16 @@
 essage;%0A
-%0A
 %7D%5D)%0A.fac
@@ -910,32 +910,43 @@
 ationMessage', %5B
+'Message', 
 'PeerConnector',
@@ -948,32 +948,41 @@
 tor', function (
+Message, 
 PeerConnector) %7B
@@ -1036,74 +1036,32 @@
     
-this.data = data;%0A    this.to = data.to;%0A    this.from = data.from
+Message.call(this, data)
 ;%0A  
@@ -1356,74 +1356,32 @@
     
-this.data = data;%0A    this.to = data.to;%0A    this.from = data.from
+Message.call(this, data)
 ;%0A  
@@ -1713,74 +1713,32 @@
     
-this.data = data;%0A    this.to = data.to;%0A    this.from = data.from
+Message.call(this, data)
 ;%0A  

Refactor the message constructors.