Пример #1
0
 public void removeTransport(ConnectorTransport transport)
 {
     lock (createdTransports)
     {
         createdTransports.Remove(transport);
     }
 }
Пример #2
0
        protected internal virtual ConnectorTransport createTransport(Uri addr)
        {
            ConnectorTransport transport = new ConnectorTransport(addr, this);

            createdTransports.Add(transport);
            return(transport);
        }
Пример #3
0
 public virtual void addDisconnectedTransport(ConnectorTransport transport)
 {
     lock (awaitingEvents)
     {
         ConnectorStorageEvent ev = new ConnectorStorageEvent();
         ev.DisconnectedTransport = transport;
         awaitingEvents.AddLast(ev);
     }
     awaitEvent.Set();
 }
Пример #4
0
 public virtual void  addDisconnectedTransport(ConnectorTransport transport)
 {
     lock (awaitingEvents)
     {
         ConnectorStorageEvent ev = new ConnectorStorageEvent();
         ev.DisconnectedTransport = transport;
         awaitingEvents.AddLast(ev);
     }
     awaitEvent.Set();
 }
Пример #5
0
 public virtual void  removeAwaitingTransport(ConnectorTransport transport)
 {
     lock (awaitingEvents)
     {
         foreach (ConnectorStorageEvent ev in awaitingEvents)
         {
             if (ev.TransportToConnect != null && ev.TransportToConnect.Equals(transport))
             {
                 awaitingEvents.Remove(ev);
                 break;
             }
         }
     }
 }
Пример #6
0
        public virtual ITransport getTransport(Uri addr)
        {
            ConnectorTransport transport = null;

            //bool created = false;
            lock (createdTransports)
            {
                transport = createTransport(addr);
                //created = true;
            }

            /*if (created)
             * {
             *      connectorStorage.addAwaitingTransport(transport);
             *      transport.finishConnect();
             * }*/
            return(transport);
        }
Пример #7
0
 public virtual void  Run()
 {
     do
     {
         ConnectorStorage.ConnectorStorageEvent ev = storage.getAwaitingEvent();
         if (ev != null)
         {
             ConnectorTransport transport = ev.TransportToConnect;
             if (transport != null)
             {
                 System.Console.Out.WriteLine("Connecting started for " + transport.getAddr());
                 bool connected = false;
                 try
                 {
                     connected = transport.connect();
                     if (connected)
                     {
                         transport.onConnected();
                     }
                 }
                 catch (Exception)
                 {
                     connected = false;
                 }
                 if (!connected)
                 {
                     System.Console.Out.WriteLine("Unable to connect for " + transport.getAddr());
                     transport.setSocket(null);
                     transport.onNotConnected();
                 }
             }
             else if (ev.DisconnectedTransport != null)
             {
                 transport = ev.DisconnectedTransport;
                 transport.onDisconnect();
             }
         }
     }while (!finish);
 }
Пример #8
0
 public virtual void removeAwaitingTransport(ConnectorTransport transport)
 {
     lock (awaitingEvents)
     {
         foreach(ConnectorStorageEvent ev in awaitingEvents)
         {
             if (ev.TransportToConnect != null && ev.TransportToConnect.Equals(transport))
             {
                 awaitingEvents.Remove(ev);
                 break;
             }
         }
     }
 }
Пример #9
0
 public virtual void  reconnect(ConnectorTransport transport)
 {
     connectorStorage.addAwaitingTransport(transport);
 }