Exemplo n.º 1
0
        /// <summary>A rendezvous service for finding remote TAs and sharing
        /// our TA, so that peers can become connected.</summary>
        public XmppDiscovery(ITAHandler ta_handler, XmppService xmpp, string realm) :
            base(ta_handler)
        {
            _realm = realm;
            _xmpp  = xmpp;
            _ready = 0;
            _xmpp.Register(typeof(XmppTARequest), HandleRequest);
            _xmpp.Register(typeof(XmppTAReply), HandleReply);
            _xmpp.OnStreamInit += XmppTAFactory.HandleStreamInit;

            // Operations aren't valid until Xmpp has authenticated with the servers
            xmpp.OnAuthenticate += HandleAuthenticate;
            if (xmpp.IsAuthenticated)
            {
                HandleAuthenticate(null);
            }
        }
Exemplo n.º 2
0
        protected void HandleAuthenticate(object sender)
        {
            if (Interlocked.Exchange(ref _ready, 1) == 1)
            {
                return;
            }

            _local_ta  = new XmppTransportAddress(_xmpp.JID);
            _local_tas = new ArrayList(1);
            _local_tas.Add(_local_ta as TransportAddress);
            _xmpp.Register(typeof(XmppRelay), HandleData);
        }
Exemplo n.º 3
0
    public JabberNetwork(string uid, string password, 
      string host, string port) {
      _addresses = ImmutableDictionary<string, string>.Empty;
      _fingerprints = ImmutableDictionary<string, string>.Empty;
      _doc = new XmlDocument();
      _port = Int32.Parse(port);
      _host = host;
      _data = String.Empty;
      _message = "Offline";
      _uid = uid;
      _password = password;
      _auto_connect = false;
      _timer = new Timer(TimerHandler, null, PUB_PERIOD, PUB_PERIOD);

      _xmpp = new XmppService(uid, password, _port);
      _xmpp.Register(typeof(SvpnMsg), HandleSvpnMsg);
      _xmpp.OnStreamInit += SvpnFactory.HandleStreamInit;
      _xmpp.OnAuthenticate += HandleAuthenticate;
      _xmpp.OnAuthError += HandleAuthError;
      _xmpp.OnPresence += HandlePresence;
      _xmpp.OnError += HandleError;
    }