Beispiel #1
0
 public virtual void CloseConnection()
 {
     IConnectionListener closedListener = null;
     ServerManager connManager = null;
     MyServerListener asyncListener = null;
     LSClient subClient = null;
     lock (this.connMutex)
     {
         lock (this.stateMutex)
         {
             if (this.subClient != null)
             {
                 subClient = this.subClient;
                 this.subClient = null;
             }
             else if (this.connManager != null)
             {
                 this.phase++;
                 connManager = this.connManager;
                 closedListener = this.connListener;
                 asyncListener = this.asyncListener;
                 this.connManager = null;
                 this.connListener = null;
                 this.asyncListener = null;
             }
             else
             {
                 return;
             }
         }
     }
     if (subClient != null)
     {
         subClient.CloseConnection();
     }
     else
     {
         foreach (ITableManager manager2 in connManager.Close())
         {
             manager2.NotifyUnsub();
         }
         asyncListener.OnClosed(closedListener);
     }
 }
Beispiel #2
0
 public virtual void CloseConnection()
 {
     IConnectionListener activeListener = null;
     ServerManager closingManager = null;
     MyServerListener closeListener = null;
     LSClient closingSubClient = null;
     lock (this.stateMutex)
     {
         this.phase++;
         if (this.subClient != null)
         {
             closingSubClient = this.subClient;
             this.subClient = null;
         }
         else if (this.connManager != null)
         {
             closingManager = this.connManager;
             activeListener = this.connListener;
             closeListener = this.asyncListener;
             this.connManager = null;
             this.connListener = null;
             this.asyncListener = null;
         }
         else
         {
             return;
         }
     }
     if (closingSubClient != null)
     {
         closingSubClient.CloseConnection();
     }
     else
     {
         CloseFlushing(closingManager, closeListener, activeListener);
     }
 }
Beispiel #3
0
 public virtual void OpenConnection(ConnectionInfo info, IConnectionListener listener)
 {
     int currPhase;
     object CS$2$0000;
     lock ((CS$2$0000 = this.stateMutex))
     {
         this.CloseConnection();
         currPhase = ++this.phase;
     }
     ConnectionInfo myInfo = (ConnectionInfo) info.Clone();
     if (myInfo.EnableStreamSense && !myInfo.Polling)
     {
         LSClient testClient = new LSClient();
         ExtConnectionListener myListener = new ExtConnectionListener(listener);
         ConnectionInfo mySubInfo = (ConnectionInfo) info.Clone();
         mySubInfo.EnableStreamSense = false;
         new Thread(delegate {
             try
             {
                 testClient.OpenConnection(mySubInfo, myListener);
             }
             catch (Exception)
             {
             }
         }) { IsBackground = true }.Start();
         if (!myListener.WaitStreamingTimeoutAnswer())
         {
             lock ((CS$2$0000 = this.stateMutex))
             {
                 if (currPhase == this.phase)
                 {
                     this.subClient = testClient;
                 }
                 else
                 {
                     AsynchCloseConnection(testClient);
                     return;
                 }
             }
             myListener.FlushAndStart();
         }
         else
         {
             AsynchCloseConnection(testClient);
             lock ((CS$2$0000 = this.stateMutex))
             {
                 if (currPhase != this.phase)
                 {
                     return;
                 }
             }
             LSClient pollClient = new LSClient();
             myInfo.Polling = true;
             pollClient.OpenConnection(myInfo, listener);
             lock ((CS$2$0000 = this.stateMutex))
             {
                 if (currPhase == this.phase)
                 {
                     this.subClient = pollClient;
                 }
                 else
                 {
                     AsynchCloseConnection(pollClient);
                 }
             }
         }
     }
     else
     {
         MyServerListener serverListener = new MyServerListener(this, listener, currPhase);
         bool ok = false;
         try
         {
             ServerManager newManager = new ServerManager(myInfo, serverListener);
             newManager.Connect();
             ok = true;
             lock ((CS$2$0000 = this.stateMutex))
             {
                 if (currPhase == this.phase)
                 {
                     this.connListener = listener;
                     this.asyncListener = serverListener;
                     this.connManager = newManager;
                 }
                 else
                 {
                     CloseFlushing(newManager, serverListener, listener);
                     return;
                 }
             }
             newManager.Start();
         }
         finally
         {
             if (!ok)
             {
                 serverListener.OnClosed(null);
             }
         }
     }
 }
Beispiel #4
0
 private static void CloseFlushing(ServerManager closingManager, MyServerListener closeListener, IConnectionListener activeListener)
 {
     foreach (ITableManager info in closingManager.Close())
     {
         info.NotifyUnsub();
     }
     closeListener.OnClosed(activeListener);
 }
Beispiel #5
0
 public virtual void OpenConnection(ConnectionInfo info, IConnectionListener listener)
 {
     ConnectionInfo info2 = (ConnectionInfo) info.Clone();
     info2.useGetForStreaming = true;
     lock (this.connMutex)
     {
         object obj3;
         this.CloseConnection();
         if (info2.enableStreamSense && !info2.isPolling)
         {
             ThreadStart start = null;
             LSClient testClient = new LSClient();
             ExtConnectionListener myListener = new ExtConnectionListener(listener);
             ConnectionInfo mySubInfo = (ConnectionInfo) info.Clone();
             mySubInfo.enableStreamSense = false;
             new Thread(() => {
                 try
                 {
                     testClient.OpenConnection(mySubInfo, myListener);
                 }
                 catch (Exception)
                 {
                 }
             }).Start();
             if (!myListener.WaitStreamingTimeoutAnswer())
             {
                 lock ((obj3 = this.stateMutex))
                 {
                     this.subClient = testClient;
                 }
                 myListener.FlushAndStart();
             }
             else
             {
                 if (start == null)
                 {
                     start = delegate {
                         testClient.CloseConnection();
                     };
                 }
                 new Thread(start).Start();
                 LSClient client = new LSClient();
                 info2.isPolling = true;
                 client.OpenConnection(info2, listener);
                 lock ((obj3 = this.stateMutex))
                 {
                     this.subClient = client;
                 }
             }
         }
         else
         {
             int num;
             lock ((obj3 = this.stateMutex))
             {
                 num = this.phase + 1;
             }
             MyServerListener asyncListener = new MyServerListener(this, listener, num);
             bool flag2 = false;
             try
             {
                 ServerManager manager = new ServerManager(info2, asyncListener);
                 manager.Connect();
                 lock ((obj3 = this.stateMutex))
                 {
                     this.connListener = listener;
                     this.asyncListener = asyncListener;
                     this.phase = num;
                     this.connManager = manager;
                 }
                 flag2 = true;
                 manager.Start();
             }
             finally
             {
                 if (!flag2)
                 {
                     asyncListener.OnClosed(null);
                 }
             }
         }
     }
 }
 public virtual void OpenConnection(ConnectionInfo info, IConnectionListener listener)
 {
     lock (this.connMutex)
     {
         int num;
         object obj3;
         this.CloseConnection();
         lock ((obj3 = this.stateMutex))
         {
             num = this.phase + 1;
         }
         ServerManager.IServerListener asyncListener = new MyServerListener(this, num);
         ServerManager manager = new ServerManager(info, listener, asyncListener);
         lock ((obj3 = this.stateMutex))
         {
             this.connListener = listener;
             this.phase = num;
             this.connManager = manager;
         }
         manager.Start();
     }
 }