File: Service1.cs

package info (click to toggle)
websockify 0.9.0%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 504 kB
  • sloc: python: 2,859; cs: 142; ansic: 55; makefile: 33; sh: 22
file content (41 lines) | stat: -rw-r--r-- 1,170 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;

namespace MELT_Command_Websocket
{
    public partial class Service1 : ServiceBase
    {
        Process websockify;
        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {

            string configpath = AppDomain.CurrentDomain.BaseDirectory + "\\noVNCConfig.ini";
            string sockifypath = AppDomain.CurrentDomain.BaseDirectory + "\\websockify.exe";
            //Load commandline arguements from config file.
            StreamReader streamReader = new StreamReader(configpath);
            string arguements = streamReader.ReadLine();
            streamReader.Close();
           
            //Start websockify.
            websockify = System.Diagnostics.Process.Start(sockifypath, arguements);
        }

        protected override void OnStop()
        {
            //Service stopped. Close websockify.
            websockify.Kill();
        }
    }
}