CydinBuildService.BuildContext.Connect C# (CSharp) Method

Connect() public method

public Connect ( ) : bool
return bool
        public bool Connect()
        {
            if (!Server.ConnectBuildService ())
                return false;

            if (LocalSettings.LiveEventsConnection) {
                if (eventsThread != null) {
                    eventsThread.Abort ();
                    eventsThread = null;
                }
                try {
                    WebRequest req = HttpWebRequest.Create (ServerUrl + "/service/events");
                    req.ConnectionGroupName = "EventListener";
                    req.Timeout = Timeout.Infinite;
                    eventsReader = new StreamReader (req.GetResponse ().GetResponseStream ());

                    eventsThread = new Thread (ReadEvents);
                    eventsThread.IsBackground = true;
                    eventsThread.Start ();
                } catch {
                    return false;
                }
            }
            return true;
        }

Usage Example

Example #1
0
 bool ConnectToServer(BuildContext ctx)
 {
     try {
         if (ctx.Connect())
         {
             ctx.Connected = true;
             return(true);
         }
         else
         {
             if (ctx.FirstNotAuthorised)
             {
                 LogService.WriteLine("ERROR: Connection to server not authorized.");
                 LogService.WriteLine("To enable connections from this service, go to the administration page");
                 LogService.WriteLine("in the server and click on the Change Service option.");
                 ctx.FirstNotAuthorised = false;
             }
             else
             {
                 LogService.WriteLine("Connection not authorized. Trying again.");
             }
         }
     } catch (Exception ex) {
         LogService.WriteLine("Connection failed: " + ex.Message);
     }
     ctx.Connected = false;
     return(false);
 }
All Usage Examples Of CydinBuildService.BuildContext::Connect