Пример #1
0
        public void StartClient(string url, string script, string name, string port)
        {
            channel = new TcpClientChannel("client", null);
            ChannelServices.RegisterChannel(channel, false);
            server = (IServerInterface)Activator.GetObject(typeof(IServerInterface), url);
            string[] lines = System.IO.File.ReadAllLines(script);
            // Display the file contents by using a foreach loop.
            System.Console.WriteLine("Running script...");

            foreach (string line in lines)
            {
                if (!String.IsNullOrEmpty(line))
                {
                    if (repeat == 0 || line.Contains("end-repeat"))
                    {
                        List <string> initialLineArray = line.Split(' ').ToList();
                        if (initialLineArray.Count() > 1)
                        {
                            List <string> lineSeperated = Regex.Split(constructLine(initialLineArray[1]), @"(?!<(?:\(|\[)[^)\]]+),(?![^(\[]+(?:\)|\]))").ToList();
                            initialLineArray.RemoveAt(1);
                            initialLineArray.AddRange(lineSeperated);
                        }

                        Parser(initialLineArray, name, port);
                    }
                    else
                    {
                        linesToRepeat.Add(line);
                    }
                }
            }
        }
Пример #2
0
        public void DestroyServerConnection()
        {
            serverInterface.Close();
            serverInterface = null;

            server = null;
        }
Пример #3
0
        public ServerLibraryShadow(IServerInterface serverInterface, IMessageQueue messageQueue)
        {
            this.serverInterface = serverInterface;
            this.messageQueue    = messageQueue;

            this.stateChecker = new PeriodicWorkDispatcher(messageQueue, 5000, UpdateLibrary);
        }
Пример #4
0
 /// <summary>
 /// Construct an <see cref="InstanceSelector"/>
 /// </summary>
 /// <param name="I">An <see cref="IServerInterface"/> connected a the <see cref="ITGSService"/></param>
 public InstanceSelector(IServerInterface I)
 {
     InitializeComponent();
     InstanceListBox.MouseDoubleClick += InstanceListBox_MouseDoubleClick;
     masterInterface = I;
     RefreshInstances();
 }
Пример #5
0
 static void ReplaceInterface(IServerInterface I)
 {
     currentInterface                     = I;
     ConsoleCommand.Interface             = I;
     InstanceRootCommand.currentInterface = I;
     saidSrvVersion = false;
 }
Пример #6
0
        public void RequestMostRecent()
        {
            string mypath     = System.Reflection.Assembly.GetEntryAssembly().Location;
            string finalpath  = mypath.Substring(0, mypath.Length - 10);
            string newpath    = Path.GetFullPath(Path.Combine(finalpath, @"..\..\"));
            string pathToList = newpath + "ListaServers.txt";

            string[] lines = System.IO.File.ReadAllLines(pathToList);
            foreach (string line in lines)
            {
                //port : name
                string[] args = line.Split(':');

                int    server_port = Int32.Parse(args[0]);
                string server_name = args[1];

                try
                {
                    string           url         = "tcp://localhost:" + server_port + "/" + server_name;
                    TcpClientChannel channelnovo = new TcpClientChannel(server_name, null);
                    ChannelServices.RegisterChannel(channelnovo, false);
                    IServerInterface servernovo = (IServerInterface)Activator.GetObject(typeof(IServerInterface), url);
                    if (servernovo.GetNumOps() > numOps)
                    {
                        tupleSpace = servernovo.GetTupleSpace();
                    }
                    ChannelServices.UnregisterChannel(channelnovo);
                }
                catch { }
            }
        }
Пример #7
0
 /// <summary>
 /// 启动插件
 /// </summary>
 /// <param name="serverInterface"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool Start(IServerInterface serverInterface, string id)
 {
     ServerInterface      = serverInterface;
     Log.ErroStringEvent += Log_ErroStringEvent;
     this.id              = id;
     return(true);
 }
Пример #8
0
        void VerifyAndConnect(IServerInterface I)
        {
            try
            {
                var res = I.ConnectionStatus(out string error);
                if (!res.HasFlag(ConnectivityLevel.Connected))
                {
                    MessageBox.Show("Unable to connect to service! Error: " + error);
                    return;
                }
                if (!res.HasFlag(ConnectivityLevel.Authenticated))
                {
                    MessageBox.Show("Authentication error: Username/password/windows identity is not authorized! Ensure you are a system administrator or in the correct Windows group on the service machine.");
                    return;
                }

                new InstanceSelector(I).Show();
                Close();
            }
            catch
            {
                I.Dispose();
                throw;
            }
        }
Пример #9
0
 public NewDLLFunctions(EntityDictionary entityDictionary, Wrapper wrapper, IServerInterface serverInterface, IEntities serverEntities)
 {
     EntityDictionary = entityDictionary ?? throw new ArgumentNullException(nameof(entityDictionary));
     Wrapper          = wrapper ?? throw new ArgumentNullException(nameof(wrapper));
     ServerInterface  = serverInterface ?? throw new ArgumentNullException(nameof(serverInterface));
     ServerEntities   = serverEntities ?? throw new ArgumentNullException(nameof(serverEntities));
 }
Пример #10
0
        void CheckForExistingVersion()
        {
            Interface = new ServerInterface();
            var verifiedConnection = Interface.ConnectionStatus().HasFlag(ConnectivityLevel.Administrator);

            try
            {
                VersionLabel.Text = Interface.GetServiceComponent <ITGSService>().Version();
                var splits      = VersionLabel.Text.Split(' ');
                var realVersion = new Version(splits[splits.Length - 1].Substring(1));
                var isV0        = realVersion < new Version(3, 1, 0, 0);
                if (isV0)                 //OH GOD!!!!
                {
                    MessageBox.Show("Upgrading from version 3.0 may trigger a bug that can delete /config and /data. IT IS STRONGLY RECCOMMENDED THAT YOU BACKUP THESE FOLDERS BEFORE UPDATING!", "Warning");
                }
                var isUnderV2 = isV0 || realVersion < new Version(3, 2, 0, 0);
                if (isUnderV2)
                {
                    //Friendly reminger
                    MessageBox.Show("Upgrading to service version 3.2 will break the 3.1 DMAPI. It is recommended you update your game to the 3.2 API before updating the servive to avoid having to trigger hard restarts.", "Note");
                }
                attemptNetSettingsMigration = isUnderV2;
            }
            catch
            {
                if (verifiedConnection)
                {
                    VersionLabel.Text = "< v3.0.85.0 (Missing ITGService.Version())";
                }
            }
        }
Пример #11
0
 /// <summary>
 /// Standard-Konstruktor, welcher u.a. den
 /// Thread für diese Verbindung erzeugt.
 /// </summary>
 /// <param name="socket">Verbindungssocket</param>
 public ServerInstance(Socket socket, IServerInterface instance)
 {
     this.socket          = socket;
     this.instanceOfClass = instance;
     // Thread erzeugen
     serverThread = new Thread(new ThreadStart(Process));
     serverThread.Start();
 }
Пример #12
0
        public ServerPlaylistShadow(IServerInterface serverInterface, IMessageQueue messageQueue)
        {
            this.serverInterface = serverInterface;
            this.messageQueue    = messageQueue;

            actualPlaylist = new List <MultimediaItem>();

            this.stateChecker = new PeriodicWorkDispatcher(messageQueue, 5000, UpdatePlaylist);
        }
Пример #13
0
        protected override void ResolveModInterfaces(IServiceProvider serviceProvider)
        {
            ServerInterface = serviceProvider.GetRequiredService <IServerInterface>();

            //Initialized in Program in their respective Get* methods
            DLLFunctions    = serviceProvider.GetRequiredService <API.Implementations.DLLFunctions>();
            NewDLLFunctions = serviceProvider.GetRequiredService <API.Implementations.NewDLLFunctions>();
            EngineOverrides = serviceProvider.GetRequiredService <API.Implementations.EngineOverrides>();
        }
Пример #14
0
 /// <summary>
 /// Construct a <see cref="TestMergeManager"/>
 /// </summary>
 /// <param name="interfaceToUse">The <see cref="IServerInterface"/> to use for managing the <see cref="ITGInstance"/></param>
 /// <param name="clientToUse">The <see cref="GitHubClient"/> to use for getting pull request information</param>
 public TestMergeManager(IServerInterface interfaceToUse, GitHubClient clientToUse)
 {
     InitializeComponent();
     DialogResult = DialogResult.Cancel;
     UpdateToRemoteRadioButton.Checked = true;
     currentInterface              = interfaceToUse;
     client                        = clientToUse;
     Load                         += PullRequestManager_Load;
     PullRequestListBox.ItemCheck += PullRequestListBox_ItemCheck;
 }
Пример #15
0
        public void CreateServerConnection(string serverAddress)
        {
            AutoManagingAsynchronousSocketInterface messageInterface = new AutoManagingAsynchronousSocketInterface(serverAddress, NetworkStandards.SOCKET_PORT, messageQueue, log);

            serverInterface = new NetworkServerInterface(messageInterface, messageQueue);
            //serverInterface = new MockServerInterface(messageQueue);
            serverInterface.Disconnect += OnDisconnect;

            server = new Server(serverInterface, messageQueue, log);
        }
Пример #16
0
 /// <summary>
 /// 开启插件
 /// </summary>
 /// <param name="serverInterface"></param>
 /// <returns></returns>
 public bool Start(IServerInterface serverInterface, string id)
 {
     ServerInterface             = serverInterface;
     this.id                     = id;
     faceMainThread              = new Thread(faceMainThreadRun);
     faceMainThread.IsBackground = true;
     faceMainThread.SetApartmentState(ApartmentState.STA);
     faceMainThread.Start();
     return(true);
 }
Пример #17
0
 /// <summary>
 /// Initializes RPC. Called when receiving a "Initialize-Connection" message
 /// </summary>
 static void InitializeServerRPC(PacketHeader header, Connection connection, string message)
 {
     //Add a event handler to handle a shutdown of the connection
     connection.AppendShutdownHandler(new NetworkComms.ConnectionEstablishShutdownDelegate((c) => MDI_Container.staticMdi_Container.BeginInvoke(MDI_Container.staticMdi_Container.DLostConnection)));
     //Remove the handler that called this function
     NetworkComms.RemoveGlobalIncomingPacketHandler <string>("Initialize-Connection", InitializeServerRPC);
     //Get the servers RPC interface
     RemoteServerInterface = RemoteProcedureCalls.Client.CreateProxyToPublicNamedInstance <IServerInterface>(connection, "Server", out RPCInstanceID, new SendReceiveOptions <ProtobufSerializer>());
     MDI_Container.staticMdi_Container.mdi_Join.Invoke(MDI_Forms.MDI_Join.DJoinResult, new object[] { true });
 }
Пример #18
0
            public void OnServerInfoReceived(object sender, ServerInfoEventArgs eventArgs)
            {
                string serverName = eventArgs.ServerName;

                listener(serverName);

                IServerInterface serverInterface = sender as IServerInterface;

                serverInterface.ServerInfo -= OnServerInfoReceived;
            }
Пример #19
0
        public ServerPlayerShadow(IServerInterface serverInterface, IMessageQueue messageQueue)
        {
            this.serverInterface = serverInterface;
            this.messageQueue    = messageQueue;

            this.playing          = false;
            this.activeMultimedia = null;
            this.playbackPosition = 0;

            this.stateChecker = new PeriodicWorkDispatcher(messageQueue, 5000, UpdatePlayer);
        }
Пример #20
0
        public void Crash(string processName)
        {
            IServerInterface server = GetProxyObject(processName, null);

            try
            {
                server.Crash();
            }
            catch (Exception e)
            {
                Console.WriteLine("Server killed : " + processName);
            }
        }
Пример #21
0
        //NEED A INSTANCE OF SERVER ALREADY UP - > WITH ONLY PPM
        public void Server(string processName, string url, string min, string max)
        {
            string[] url_port = url.Split('/');
            string   urlFinal = "tcp://localhost:10000/" + url_port.ElementAt(url_port.Length - 1) + "_PPM";

            IServerInterface server = GetProxyObject(processName, urlFinal);

            IServerInterface server2 = GetProxyObject(processName, url);

            serversUp.Add(new KeyValuePair <string, IServerInterface>(processName, server2));
            Console.WriteLine("ServerID added " + processName);

            server.Server(url, min, max);
        }
Пример #22
0
        public CLICommand(IServerInterface I)
        {
            var tmp = new List <Command> {
                new UpdateCommand(), new TestmergeCommand(), new RepoCommand(), new BYONDCommand(), new DMCommand(), new DDCommand(), new ConfigCommand(), new IRCCommand(), new DiscordCommand(), new AutoUpdateCommand(), new SetAutoUpdateCommand()
            };

            if (I.ConnectToInstance().HasFlag(ConnectivityLevel.Administrator))
            {
                tmp.Add(new AdminCommand());
            }
            if (I.ConnectionStatus().HasFlag(ConnectivityLevel.Administrator))
            {
                tmp.Add(new ServiceCommand());
            }
            Children = tmp.ToArray();
        }
Пример #23
0
        private bool BroadcastRemove(DIDATuple didatuple, string[] lines)
        {
            int  numberOfActiveServers = 1;
            bool ack          = false;
            int  numberOfAcks = 1;

            do
            {
                foreach (string line in lines)
                {
                    //port : name : priority
                    string[] args        = line.Split(':');
                    int      server_port = Int32.Parse(args[0]);
                    string   server_name = args[1];

                    if (didatuple.getName() != server_name)
                    {
                        try
                        {
                            string           url         = "tcp://localhost:" + server_port + "/" + server_name;
                            TcpClientChannel channelnovo = new TcpClientChannel(server_name, null);
                            ChannelServices.RegisterChannel(channelnovo, false);
                            IServerInterface servernovo = (IServerInterface)Activator.GetObject(typeof(IServerInterface), url);

                            ack = servernovo.XLBroadcastRemove(didatuple);
                            ChannelServices.UnregisterChannel(channelnovo);

                            if (ack)
                            {
                                numberOfAcks++;
                            }
                            else
                            {
                                break;
                            }

                            numberOfActiveServers++;
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }
            } while (numberOfAcks != numberOfActiveServers);

            return(true);
        }
Пример #24
0
        public void Server2(string processName, string url, string min, string max)
        {
            Process serverProcess = new Process();
            string  mypath        = System.Reflection.Assembly.GetEntryAssembly().Location;

            serverProcess.StartInfo.FileName = Path.GetFullPath(Path.Combine(mypath, @"C:\Users\ASUS\Desktop\IST\DAD\proj\DIDA-TUPLE\Server\bin\Debug\Server.exe"));

            serverProcess.StartInfo.Arguments = url + " " + min + " " + max;
            serverProcess.Start();

            //string[] url_port = url.Split('/');
            //string urlFinal = "tcp://localhost:10000/" + url_port.ElementAt(url_port.Length - 1) + "_PPM";

            IServerInterface server = GetProxyObject(processName, url);

            serversUp.Add(new KeyValuePair <string, IServerInterface>(processName, server));
        }
Пример #25
0
        private bool BroadcastAdd(DIDATuple didaAdd)
        {
            int numberOfActiveServers = 1;
            int numberOfAcknowledge   = 1;

            string mypath     = System.Reflection.Assembly.GetEntryAssembly().Location;
            string finalpath  = mypath.Substring(0, mypath.Length - 13);
            string newpath    = Path.GetFullPath(Path.Combine(finalpath, @"..\..\"));
            string pathToList = newpath + "ListaServers.txt";

            string[] lines = System.IO.File.ReadAllLines(pathToList);

            foreach (string line in lines)
            {
                //port : name : priority
                string[] args        = line.Split(':');
                int      server_port = Int32.Parse(args[0]);
                string   server_name = args[1];

                if (didaAdd.getName() != server_name)
                {
                    try
                    {
                        string           url         = "tcp://localhost:" + server_port + "/" + server_name;
                        TcpClientChannel channelnovo = new TcpClientChannel(server_name, null);
                        ChannelServices.RegisterChannel(channelnovo, false);
                        IServerInterface servernovo = (IServerInterface)Activator.GetObject(typeof(IServerInterface), url);

                        if (servernovo.XLBroadcastAdd(didaAdd))
                        {
                            numberOfAcknowledge++;
                        }

                        ChannelServices.UnregisterChannel(channelnovo);

                        numberOfActiveServers++;
                    }
                    catch (Exception e)
                    {
                    }
                }
            }

            return(numberOfAcknowledge >= (numberOfActiveServers / 2) + 1);
        }
Пример #26
0
        public MWRProcesser(IServerInterface webServ, string machineGuid, string authToken)
        {
            stateProcesser = new StateProcesser(webServ, machineGuid, authToken);
            stateTimer = new Timer(1000);
            stateTimer.Elapsed += new ElapsedEventHandler(stateTimer_Elapsed);
            stateProcesser.ProcessCompleted += new Notifier(stateProcesser_ProcessCompleted);
            stateProcesser.UpdateCompleted += new Notifier(stateProcesser_UpdateCompleted);
            stateProcesser.ProcessStarted += new Notifier(stateProcesser_ProcessStarted);
            stateProcesser.Message += new TextNotifier(stateProcesser_Message);

            taskProcesser = new TaskProcesser(webServ, machineGuid, authToken);
            taskTimer = new Timer(2000);
            taskTimer.Elapsed += new ElapsedEventHandler(taskTimer_Elapsed);
            taskProcesser.ProcessStarted += new Notifier(taskProcesser_ProcessStarted);
            taskProcesser.UpdateCompleted += new Notifier(taskProcesser_UpdateCompleted);
            taskProcesser.ProcessCompleted += new Notifier(taskProcesser_ProcessCompleted);
            taskProcesser.Message += new TextNotifier(taskProcesser_Message);
        }
Пример #27
0
        /// <summary>
        /// Haupt-Thread, wartet auf neue Client-Verbindungen
        /// </summary>
        private void MainListener()
        {
            // Alle Netzwerk-Schnittstellen abhören
            TcpListener listener = new TcpListener(ipAddress, serverListenPort);

            status.NewMessage("Listening on port " + serverListenPort + "...");
            try
            {
                listener.Start();
                // Solange Clients akzeptieren, bis das
                // angegebene Maximum erreicht ist
                while (status.CurrentConnections <= maxServerConnections)
                {
                    while (!listener.Pending())
                    {
                        Thread.Sleep(sleepTime);
                    }
                    Socket newSocket = listener.AcceptSocket();
                    if (newSocket != null)
                    {
                        status.CurrentConnections++;
                        // Mitteilung bzgl. neuer Clientverbindung
                        status.NewMessage("Neue Client-Verbindung (" +
                                          "IP: " + newSocket.RemoteEndPoint + ", " +
                                          "Port " + ((IPEndPoint)newSocket.LocalEndPoint).Port.ToString() + ")");
                        // Instanz der serverseitigen Verwaltungsklasse erzeugen
                        IServerInterface x = (IServerInterface)Activator.CreateInstance(serverClass);
                        x.SetConnectionData(newSocket);
                        ServerInstance newConnection = new ServerInstance(newSocket, x);
                        Clients.Add(newConnection);
                    }
                }
            }
            catch (ThreadAbortException ex)
            {
                status.NewMessage("Server wird beendet.\r\n" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Fehler bei Verbindungserkennung", ex);
            }
        }
Пример #28
0
 public DLLFunctions(
     EngineFuncs engineFuncs,
     IGlobalVars globals,
     EntityDictionary entityDictionary,
     IServerInterface serverInterface,
     IEntities entities,
     IGameClients gameClients,
     INetworking networking,
     IPersistence persistence,
     IPlayerPhysics playerPhysics)
 {
     EngineFuncs      = engineFuncs ?? throw new ArgumentNullException(nameof(engineFuncs));
     Globals          = globals ?? throw new ArgumentNullException(nameof(globals));
     EntityDictionary = entityDictionary ?? throw new ArgumentNullException(nameof(entityDictionary));
     ServerInterface  = serverInterface ?? throw new ArgumentNullException(nameof(serverInterface));
     Entities         = entities ?? throw new ArgumentNullException(nameof(entities));
     GameClients      = gameClients ?? throw new ArgumentNullException(nameof(gameClients));
     Networking       = networking ?? throw new ArgumentNullException(nameof(networking));
     Persistence      = persistence ?? throw new ArgumentNullException(nameof(persistence));
     PlayerPhysics    = playerPhysics ?? throw new ArgumentNullException(nameof(playerPhysics));
 }
Пример #29
0
        private void BroadcastTake(DIDATuple didaTake)
        {
            string mypath     = System.Reflection.Assembly.GetEntryAssembly().Location;
            string finalpath  = mypath.Substring(0, mypath.Length - 10);
            string newpath    = Path.GetFullPath(Path.Combine(finalpath, @"..\..\"));
            string pathToList = newpath + "ListaServers.txt";

            string[] lines = System.IO.File.ReadAllLines(pathToList);
            foreach (string line in lines)
            {
                //port : name
                string[] args = line.Split(':');

                int    server_port = Int32.Parse(args[0]);
                string server_name = args[1];

                if (didaTake.getName() != server_name)
                {
                    try
                    {
                        string           url         = "tcp://localhost:" + server_port + "/" + server_name;
                        TcpClientChannel channelnovo = new TcpClientChannel(server_name, null);
                        ChannelServices.RegisterChannel(channelnovo, false);
                        IServerInterface servernovo = (IServerInterface)Activator.GetObject(typeof(IServerInterface), url);
                        DIDATuple        didaToSend = didaTake;
                        didaToSend.setName(server_name);

                        servernovo.Take(didaToSend, null, 0);
                        ChannelServices.UnregisterChannel(channelnovo);
                    }
                    catch
                    {
                    }
                }
            }
        }
Пример #30
0
 /// <summary>
 /// Constructs a <see cref="ControlPanel"/>
 /// </summary>
 /// <param name="I">The <see cref="IServerInterface"/> for the <see cref="ControlPanel"/></param>
 public ControlPanel(IServerInterface I)
 {
     InitializeComponent();
     FormClosed += ControlPanel_FormClosed;
     Interface   = I;
     if (Interface.IsRemoteConnection)
     {
         var splits = Interface.GetServiceComponent <ITGLanding>().Version().Split(' ');
         Text = String.Format("TGS {0}: {1}:{2}", splits[splits.Length - 1], Interface.HTTPSURL, Interface.HTTPSPort);
     }
     Text += " Instance: " + I.InstanceName;
     if (Interface.VersionMismatch(out string error) && MessageBox.Show(error, "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
     {
         Close();
         return;
     }
     Panels.SelectedIndexChanged += Panels_SelectedIndexChanged;
     Panels.SelectedIndex        += Math.Min(Properties.Settings.Default.LastPageIndex, Panels.TabCount - 1);
     InitRepoPage();
     InitBYONDPage();
     InitServerPage();
     UpdateSelectedPanel();
     InstancesInUse.Add(I.InstanceName, this);
 }
Пример #31
0
 private void getInstanceOfServer()
 {
     fileServer = FileServer.GetInstance();
 }