Exemplo n.º 1
0
 private bool canConnect()
 {
     try {
         if (_client != null && _client.IsConnected)
             return true;
         var instance = new EngineLocator().GetInstance(_path);
         if (instance == null)
             return false;
         Logger.Write("Connecting to port {0} hosted by {1} with token {2}", instance.Port, instance.ProcessID, instance.File);
         _client = new SocketClient();
         _client.Connect(instance.Port, (m) => {
                 if (RecievedMessage != null && m != null && m.Trim().Length > 0)
                     RecievedMessage(this, new MessageArgs(Guid.Empty, m));
             });
         if (_client.IsConnected) {
             Logger.Write("Connecting to editor on port: {0}", instance.Port);
             return true;
         }
         _client = null;
         return false;
     } catch (Exception ex) {
         Logger.Write(ex);
         return false;
     }
 }
Exemplo n.º 2
0
 private bool canConnect()
 {
     try {
         if (_client != null && _client.IsConnected)
         {
             return(true);
         }
         var instance = new EngineLocator().GetInstance(_path);
         if (instance == null)
         {
             return(false);
         }
         Logger.Write("Connecting to port {0} hosted by {1} with token {2}", instance.Port, instance.ProcessID, instance.File);
         _client = new SocketClient();
         _client.Connect(instance.Port, (m) => {
             if (RecievedMessage != null && m != null && m.Trim().Length > 0)
             {
                 RecievedMessage(this, new MessageArgs(Guid.Empty, m));
             }
         });
         if (_client.IsConnected)
         {
             Logger.Write("Connecting to editor on port: {0}", instance.Port);
             return(true);
         }
         _client = null;
         return(false);
     } catch (Exception ex) {
         Logger.Write(ex);
         return(false);
     }
 }
Exemplo n.º 3
0
 private bool isConnected()
 {
     try
     {
         if (_client != null && _client.IsConnected)
             return true;
         var instance = new EngineLocator().GetInstance(_path);
         if (instance == null)
             return false;
         _client = new SocketClient();
         _client.Connect(instance.Port, (m) => {
                 if (RecievedMessage != null)
                     RecievedMessage(this, new MessageArgs(Guid.Empty, m));
             });
         if (_client.IsConnected)
             return true;
         _client = null;
         return false;
     }
     catch
     {
         return false;
     }
 }