public KSPWebSocketService(IKSPAPI kspAPI, Servers.AsynchronousServer.ClientConnection clientConnection)
     : this(kspAPI)
 {
     this.clientConnection = clientConnection;
     streamTimer.Interval = streamRate;
     streamTimer.Elapsed += streamData;
     streamTimer.Enabled = true;
 }
 public KSPWebSocketService(IKSPAPI kspAPI, Servers.AsynchronousServer.ClientConnection clientConnection)
     : this(kspAPI)
 {
     this.clientConnection = clientConnection;
     streamTimer.Interval  = streamRate;
     streamTimer.Elapsed  += streamData;
     streamTimer.Enabled   = true;
 }
Exemple #3
0
 public KSPWebSocketService(IKSPAPI kspAPI, Servers.AsynchronousServer.ClientConnection clientConnection, IterationToEvent <UpdateTimerEventArgs> gameLoopEvent)
     : this(kspAPI, gameLoopEvent)
 {
     this.clientConnection = clientConnection;
     streamTimer.Interval  = streamRate;
     streamTimer.Elapsed  += streamData;
     streamTimer.Enabled   = true;
 }
 public KSPWebSocketService(IKSPAPI kspAPI, Servers.AsynchronousServer.ClientConnection clientConnection, IterationToEvent<UpdateTimerEventArgs> gameLoopEvent)
     : this(kspAPI, gameLoopEvent)
 {
     this.clientConnection = clientConnection;
     streamTimer.Interval = streamRate;
     streamTimer.Elapsed += streamData;
     streamTimer.Enabled = true;
 }
Exemple #5
0
 public bool process(Servers.AsynchronousServer.ClientConnection cc, HTTPRequest request)
 {
     if (!KSP.IO.FileInfo.CreateForType <TelemachusDataLink>(INDEX_PAGE).Exists)
     {
         throw new PageNotFoundResponsePage("Unable to find the Telemachus index page. Is it installed in the PluginData folder?");
     }
     else
     {
         throw new PageNotFoundResponsePage(
                   "Did you mean to visit the <a href=\"/" + INDEX_PAGE + "\">index page</a>?");
     }
 }
Exemple #6
0
        public bool process(Servers.AsynchronousServer.ClientConnection cc, HTTPRequest request)
        {
            DataSources dataSources = new DataSources();

            if (request.path.StartsWith(PAGE_PREFIX))
            {
                if (request.requestType == HTTPRequest.GET)
                {
                    dataRates.addUpLinkPoint(System.DateTime.Now, request.path.Length * UpLinkDownLinkRate.BITS_PER_BYTE);
                }
                else if (request.requestType == HTTPRequest.POST)
                {
                    dataRates.addUpLinkPoint(System.DateTime.Now, request.content.Length * UpLinkDownLinkRate.BITS_PER_BYTE);
                }

                try
                {
                    dataSources.vessel = kspAPI.getVessel();
                }
                catch (Exception e)
                {
                    PluginLogger.debug(e.Message + " " + e.StackTrace);
                }

                if (request.requestType == HTTPRequest.GET)
                {
                    dataRates.addDownLinkPoint(
                        System.DateTime.Now,
                        ((Servers.MinimalHTTPServer.ClientConnection)cc).Send(new OKResponsePage(
                                                                                  argumentsParse(request.path.Remove(0,
                                                                                                                     request.path.IndexOf(ARGUMENTS_START) + 1),
                                                                                                 dataSources)
                                                                                  )) * UpLinkDownLinkRate.BITS_PER_BYTE);
                }
                else if (request.requestType == HTTPRequest.POST)
                {
                    dataRates.addDownLinkPoint(
                        System.DateTime.Now,
                        ((Servers.MinimalHTTPServer.ClientConnection)cc).Send(new OKResponsePage(
                                                                                  argumentsParse(request.content,
                                                                                                 dataSources)
                                                                                  )) * UpLinkDownLinkRate.BITS_PER_BYTE);
                }

                return(true);
            }

            return(false);
        }
Exemple #7
0
        public bool process(Servers.AsynchronousServer.ClientConnection cc, HTTPRequest request)
        {
            if (request.path.StartsWith(PAGE_PREFIX))
            {
                try
                {
                    OKResponsePage page = new OKResponsePage(
                        KSPByteReader, KSPTextReader,
                        request.path.Substring(PAGE_PREFIX.Length));
                    ((Servers.MinimalHTTPServer.ClientConnection)cc).Send(page);

                    return(true);
                }
                catch
                {
                    return(false);
                }
            }

            return(false);
        }
 public IWebSocketService buildService(Servers.AsynchronousServer.ClientConnection clientConnection)
 {
     return(new KSPWebSocketService(kspAPI, clientConnection));
 }
Exemple #9
0
 public FrameEventArgs(WebSocketFrame frame, Servers.AsynchronousServer.ClientConnection clientConnection)
 {
     this.frame            = frame;
     this.clientConnection = clientConnection;
 }