示例#1
0
 public ServerManager(
     CmdServer server,
     UnityClient client)
 {
     _server = server;
     _client = client;
 }
示例#2
0
文件: SyncCmd.cs 项目: lulzzz/simias
        int RunServer()
        {
            if (host == null)
            {
                host = MyDns.GetHostName();
            }
            CmdServer server = new CmdServer(host, port);

            Console.WriteLine("server {0} started, press enter to exit", port);
            Console.ReadLine();
            server.Stop();
            return(0);
        }
示例#3
0
        public virtual void Initialize(IApplication app)
        {
            App = app;

            if (app.ScriptApp.ApplicationBuild < 935)
            {
                MessageBox.Show("Data Modeling plugin requires VisuMap 5.0.935 or higher!",
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            app.InstallPluginObject(mdScript = new ModelingScript());

            ToolStripMenuItem miPlugin = App.GetPluginMenu();
            var gm = app.ScriptApp.GuiManager;

            miPlugin.DropDownItems.Add("Model Training", null, (s, e) => gm.ShowForm(new ModelTraining(), true));
            miPlugin.DropDownItems.Add("Model Evaluation", null, (s, e) => gm.ShowForm(new ModelTest(), true));
            miPlugin.DropDownItems.Add("Model Server", null, (s, e) => gm.ShowForm(new ModelServer(), true));
            miPlugin.DropDownItems.Add("Model Manager", null, (s, e) => gm.ShowForm(new ModelManager2(), true));

            app.InstallScriptPlugin(new PythonEngine());
            //app.InstallScriptPlugin(new J8Engine());

            propMan    = new VisuMap.Lib.PropertyManager(this, "Settings", "DataModeling");
            pluginRoot = DataModeling.App.GetPluginDataNode(0, "DataModeling", propMan.NameSpace, true);
            propMan.LoadProperties(pluginRoot);
            homeDir = app.ScriptApp.GetProperty("DataModeling.HomeDir", "");
            workDir = app.ScriptApp.GetProperty("DataModeling.WorkDir", "");
            if (!homeDir.EndsWith("\\"))
            {
                homeDir += "\\";
            }
            if (!workDir.EndsWith("\\"))
            {
                workDir += "\\";
            }

            SetDefaultWorkDir();
            modelManager = new ModelManager();

            app.InstallFileImporter(new NumpyFileImport());

            cmdServer = new CmdServer();
            cmdServer.Start();
            app.ShuttingDown       += App_ShuttingDown;
            app.ApplicationStarted += App_ApplicationStarted;
        }
示例#4
0
 public void OpenPortInternal(string port)
 {
     try {
         // pass true as first param to make the server visible only to 'localhost'
         // (for testing, for exmaple)
         _cmdServer = new CmdServer(false, int.Parse(port), 1);
         OnPortOpened(this, null);
     }
     catch (Exception e) {
         Debug.Log("Failed to open port " + port);
         Debug.Log(e.Message);
         Debug.Log(e.InnerException);
         Debug.Log(e.StackTrace);
         Debug.Log(e.Data);
     }
 }
示例#5
0
            void OnDestroy()
            {
                if (_cmdServer != null)
                {
                    _cmdServer.Close();
                    _cmdServer = null;
                }

                for (int i = 0; i < _socketConnections.Count; i++)
                {
                    if (_socketConnections[i] != null && _socketConnections[i].IsConnected())
                    {
                        _socketConnections[i].Close();
                        _socketConnections[i] = null;
                    }
                }

                //if (_fusionSocket != null && _fusionSocket.IsConnected()) {
                //    _fusionSocket.Close();
                //    _fusionSocket = null;
                //}

                if (_commanderSocket != null && _commanderSocket.IsConnected())
                {
                    _commanderSocket.Close();
                    _commanderSocket = null;
                }

                if (_ksimSocket != null && _ksimSocket.IsConnected())
                {
                    _ksimSocket.Close();
                    _ksimSocket = null;
                }

                if (_adeSocket != null && _adeSocket.IsConnected())
                {
                    _adeSocket.Close();
                    _adeSocket = null;
                }
            }
示例#6
0
        /// <summary>
        /// 获取命令请求分发服务器信息命令执行
        /// </summary>
        /// <param name="context"></param>
        public override void Execute(DataContext context)
        {
            byte[] cmdData = context.CmdData;
            if (cmdData.Length != 4)
            {
                context.Flush(RespondCode.CmdDataLack);
                return;
            }

            int lastVer = BitConverter.ToInt32(cmdData.Reverse(), 0);

            if (Compiled.Debug)
            {
                cmdData.Debug("=== Support.CmdDispatch 上行数据===");
                lastVer.Debug("=== Support.CmdDispatch 上行数据 ===");
            }

            CmdConfig config         = CmdConfigs.GetCmdConfigFromStorage();
            var       cmdWithServers = config.CmdList.Where(c => c.VCode > lastVer);

            if (cmdWithServers.Count() > 0)
            {
                CmdServer result = new CmdServer
                {
                    LastVer  = cmdWithServers.Max(c => c.VCode),
                    DataList = cmdWithServers.Select(c => new KvPair {
                        Key = c.Cmd, Value = c.Server
                    }).ToList()
                };
                context.Flush <CmdServer>(result);
            }
            else
            {
                context.Flush();
            }
        }