Exemplo n.º 1
0
        /// <summary>
        /// Sets up bot instance
        /// </summary>
        public void Setup()
        {
            // Set logging level
            LogLevels logLevel;

            Enum.TryParse <LogLevels>(CoreSettings.Get("LogLevel", "Production"), out logLevel);
            Log.Level = logLevel;

            // Load instance
            Bot      = new Instance(CoreSettings.Get("Name", defaultName));
            userName = NetworkSettings.Get("Username");
            password = NetworkSettings.Get("Password");
            World    = NetworkSettings.Get("World");
            Owner    = userName;

            // Connect to network
            ConnectToUniverse();
            Log.Info("Network", "Connected to universe");

            // Set up subsystems
            SetupDatabase();
            SetupWeb();
            SetupCommands();
            SetupEvents();
            LoadServices();

            // Set up services
            ConnectToWorld();
            PerformMigrations();
            InitServices();
            Log.Info("Network", "Connected to {0}", World);

            CoreSettings.Set("Version", MigrationVersion);
            Bot.ConsoleBroadcast(ChatEffect.None, ColorInfo, "", "Services is now online; say !help for information");
        }
 private static void InitializeNetworking(string dataDir = null)
 {
     _networkSettings                   = NetworkSettings.Get(dataDir);
     _connectionManager                 = new ClientManager(_networkSettings);
     _connectionManager.OnConnected    += OnConnected;
     _connectionManager.OnDisconnected += OnDisconnected;
     _connectionManager.OnMessage      += OnMessageReceived;
 }
Exemplo n.º 3
0
        private void InitializeServer()
        {
            _networkSettings = NetworkSettings.Get(DataDir);
            _servers.Add(new TcpServer(_networkSettings.Server));

            foreach (var server in _servers)
            {
                server.Bind(this);
                server.Start();
            }
        }