Exemplo n.º 1
0
        public AgentUri(string uri)
        {
            try
            {
                var sepration1 = uri.Split('@');
                _agentName = sepration1[0];

                string scopePart = sepration1.Length == 1 ? "local:def" : sepration1[1];
                if (scopePart == "undefiend")
                {
                    _scopeUri = null;
                }
                else
                {
                    var sepration2    = scopePart.Split(':');
                    var _scopeAddress = IPAddress.Parse(sepration2[0] == "local" ? "127.0.0.1" : sepration2[0]);
                    var _scopePort    = int.Parse(sepration2[1] == "def" ? "24000" : sepration2[1]);
                    _scopeUri = new ScopeUri(_scopeAddress, _scopePort);
                }
            }
            catch
            {
                throw new Exception("Invalid uri to parse");
            }
        }
Exemplo n.º 2
0
 public Message(AgentUri Sender, string Body, ScopeUri Recievers, string Session = null)
 {
     _body           = Body;
     _nonce          = Guid.NewGuid().ToString();
     _session        = Session ?? Guid.NewGuid().ToString();
     _sender         = Sender;
     _type           = MessageType.Broadcast;
     _recieverScopes = new List <ScopeUri>()
     {
         Recievers
     };
 }
Exemplo n.º 3
0
 public void Lecture(string sentence, ScopeUri recievers)
 {
     try
     {
         new Message(Uri, sentence, recievers).Send();
     }
     catch (Exception e)
     {
         if (OnExceptionThrown != null)
         {
             OnExceptionThrown(this, e);
         }
         else
         {
             throw e;
         }
     }
 }
Exemplo n.º 4
0
 public async Task <Message> QueryAsync(string question, ScopeUri reciever, uint timeOut = 0)
 {
     try
     {
         var m = new Message(Uri, question, reciever);
         m.Send();
         return(await RecieveAsync(m.Session, timeOut));
     }
     catch (Exception e)
     {
         if (OnExceptionThrown != null)
         {
             OnExceptionThrown(this, e);
             return(null);
         }
         else
         {
             throw e;
         }
     }
 }
Exemplo n.º 5
0
 public AgentUri(string AgentName, IPAddress ScopeAddress, int ScopePort)
 {
     _agentName = AgentName;
     _scopeUri  = new ScopeUri(ScopeAddress, ScopePort);
 }
Exemplo n.º 6
0
 public AgentUri(string AgentName, ScopeUri ScopeUri)
 {
     _agentName = AgentName;
     _scopeUri  = ScopeUri;
 }