Beispiel #1
0
 public Message(AgentUri Sender, string Body, List <ScopeUri> Recievers, string Session = null)
 {
     _body           = Body;
     _nonce          = Guid.NewGuid().ToString();
     _session        = Session ?? Guid.NewGuid().ToString();
     _sender         = Sender;
     _type           = MessageType.Broadcast;
     _recieverScopes = Recievers;
 }
Beispiel #2
0
 public Message(string Nonce, string Session, string Body, MessageType Type, List <ScopeUri> RecieverScopes, List <AgentUri> RecieverAgents, AgentUri Sender)
 {
     _nonce          = Nonce;
     _session        = Session;
     _body           = Body;
     _type           = Type;
     _recieverScopes = RecieverScopes;
     _recieverAgents = RecieverAgents;
     _sender         = Sender;
 }
Beispiel #3
0
 public Message(string Body, AgentUri Reciever, Socket Socket = null, AgentUri Sender = null)
 {
     _body           = Body;
     _recieverAgents = new List <AgentUri>()
     {
         Reciever
     };
     this.Socket = Socket;
     _sender     = Sender;
     _type       = MessageType.Revelation;
 }
Beispiel #4
0
 public Message CreateReply(AgentUri Sender, string Body)
 {
     if (_type == MessageType.Revelation)
     {
         return(new Message(Body, _sender, Socket, Sender));
     }
     else
     {
         return(new Message(Sender, Body, _sender, Session));
     }
 }
Beispiel #5
0
 public Message(AgentUri Sender, string Body, AgentUri Reciever, string Session = null)
 {
     _body           = Body;
     _nonce          = Guid.NewGuid().ToString();
     _session        = Session ?? Guid.NewGuid().ToString();
     _sender         = Sender;
     _type           = MessageType.Unicast;
     _recieverAgents = new List <AgentUri>()
     {
         Reciever
     };
 }
Beispiel #6
0
 public void Say(string sentence, AgentUri reciever)
 {
     try
     {
         new Message(Uri, sentence, reciever).Send();
     }
     catch (Exception e)
     {
         if (OnExceptionThrown != null)
         {
             OnExceptionThrown(this, e);
         }
         else
         {
             throw e;
         }
     }
 }
Beispiel #7
0
 public Message Ask(string question, AgentUri reciever, uint timeOut = 0)
 {
     try
     {
         var m = new Message(Uri, question, reciever);
         m.Send();
         var r = Recieve(m.Session, timeOut);
         return(r);
     }
     catch (Exception e)
     {
         if (OnExceptionThrown != null)
         {
             OnExceptionThrown(this, e);
             return(null);
         }
         else
         {
             throw e;
         }
     }
 }
Beispiel #8
0
 public Message Reavel(string sentence, AgentUri reciever)
 {
     try
     {
         var m = new Message(sentence, reciever, Sender: Uri);
         m.Reveal();
         var reply = m.RecieveRevelation();
         return(reply);
     }
     catch (Exception e)
     {
         if (OnExceptionThrown != null)
         {
             OnExceptionThrown(this, e);
         }
         else
         {
             throw e;
         }
     }
     return(null);
 }