예제 #1
0
 public KSPWebSocketService(IKSPAPI kspAPI, Servers.AsynchronousServer.ClientConnection clientConnection)
     : this(kspAPI)
 {
     this.clientConnection = clientConnection;
     streamTimer.Interval  = streamRate;
     streamTimer.Elapsed  += streamData;
     streamTimer.Enabled   = true;
 }
예제 #2
0
 public KSPWebSocketService(IKSPAPI kspAPI, Servers.AsynchronousServer.ClientConnection clientConnection)
     : this(kspAPI)
 {
     this.clientConnection = clientConnection;
     streamTimer.Interval = streamRate;
     streamTimer.Elapsed += streamData;
     streamTimer.Enabled = true;
 }
예제 #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;
 }
        static private void startDataLink()
        {
            if (webServer == null)
            {
                try
                {
                    PluginLogger.print("Telemachus data link starting");

                    readConfiguration();

                    // Data access tools
                    vesselChangeDetector = new VesselChangeDetector(isPartless);
                    apiInstance          = new KSPAPI(JSONFormatterProvider.Instance, vesselChangeDetector, serverConfig, pluginManager);

                    // Create the dispatcher and handlers. Handlers added in reverse priority order so that new ones are not ignored.
                    webDispatcher = new KSPWebServerDispatcher();
                    webDispatcher.AddResponder(new ElseResponsibility());
                    webDispatcher.AddResponder(new IOPageResponsibility());
                    var cameraLink = new CameraResponsibility(apiInstance, rateTracker);
                    webDispatcher.AddResponder(cameraLink);
                    var dataLink = new DataLinkResponsibility(apiInstance, rateTracker);
                    webDispatcher.AddResponder(dataLink);

                    // Create the server and associate the dispatcher
                    webServer         = new HttpServer(serverConfig.ipAddress, serverConfig.port);
                    webServer.OnGet  += webDispatcher.DispatchRequest;
                    webServer.OnPost += webDispatcher.DispatchRequest;

                    // Create the websocket server and attach to the web server
                    webServer.AddWebSocketService("/datalink", () => new KSPWebSocketService(apiInstance, rateTracker));

                    // Finally, start serving requests!
                    try {
                        webServer.Start();
                    } catch (Exception ex)
                    {
                        PluginLogger.print("Error starting web server: " + ex.ToString());
                        throw;
                    }

                    PluginLogger.print("Telemachus data link listening for requests on the following addresses: ("
                                       + string.Join(", ", serverConfig.ValidIpAddresses.Select(x => x.ToString() + ":" + serverConfig.port.ToString()).ToArray())
                                       + "). Try putting them into your web browser, some of them might not work.");
                }
                catch (Exception e)
                {
                    PluginLogger.print(e.Message);
                    PluginLogger.print(e.StackTrace);
                }
            }
        }
예제 #6
0
 public DataLinkResponsibility(IKSPAPI kspAPI, UpLinkDownLinkRate rateTracker)
 {
     this.kspAPI = kspAPI;
     dataRates   = rateTracker;
 }
예제 #7
0
 public KSPWebSocketService(IKSPAPI kspAPI)
 {
     this.kspAPI = kspAPI;
 }
 public DataLinkResponsibility(IKSPAPI kspAPI, UpLinkDownLinkRate rateTracker)
 {
     this.kspAPI = kspAPI;
     dataRates = rateTracker;
 }
예제 #9
0
 public DataLinkResponsibility(Servers.AsynchronousServer.ServerConfiguration serverConfiguration, IKSPAPI kspAPI)
 {
     this.kspAPI = kspAPI;
 }
예제 #10
0
 public KSPWebSocketService(IKSPAPI kspAPI)
 {
     this.kspAPI = kspAPI;
 }
예제 #11
0
 public KSPWebSocketService(IKSPAPI kspAPI, IterationToEvent <UpdateTimerEventArgs> gameLoopEvent)
 {
     this.kspAPI             = kspAPI;
     this.gameLoopEvent      = gameLoopEvent;
     gameLoopEvent.Iterated += streamTimer.update;
 }
 public KSPWebSocketService(IKSPAPI kspAPI, IterationToEvent<UpdateTimerEventArgs> gameLoopEvent)
 {
     this.kspAPI = kspAPI;
     this.gameLoopEvent = gameLoopEvent;
     gameLoopEvent.Iterated += streamTimer.update;
 }
예제 #13
0
 public DataLinkResponsibility(Servers.AsynchronousServer.ServerConfiguration serverConfiguration, IKSPAPI kspAPI)
 {
     this.kspAPI = kspAPI;
 }
예제 #14
0
 public KSPWebSocketService(IKSPAPI api, UpLinkDownLinkRate rateTracker)
 {
     this.api  = api;
     dataRates = rateTracker;
 }