Example #1
0
        public MongoDbActor() : base(GenerateGuids.GetActorGuid(TYPEACTOR.DATABASE),
                                     GenerateGuids.GetActorGuid(TYPEACTOR.EMPTY))
        {
            _logger = LogManager.GetLogger("[MongoDB]");
            //  client = new MongoClient("mongodb://localhost:27017");

            client   = new MongoClient(MainSettings.DBUrl);
            database = client.GetDatabase(MainSettings.DatabaseName);
            _logger.Info($"DB is created, address {MainSettings.DBUrl}, db {MainSettings.DatabaseName}");

            if (!_typesRegistered)
            {
                var pack = new ConventionPack();
                pack.Add(new IgnoreExtraElementsConvention(true));
                ;
                ConventionRegistry.Register("JediumConventions", pack, t => true);

                BsonClassMap.RegisterClassMap <JediumBehaviourDBSnapshot>(cm =>
                {
                    cm.AutoMap();
                    cm.SetIsRootClass(true);
                    cm.SetIgnoreExtraElements(true);
                });

                foreach (var cls in BehaviourTypeRegistry.DBTypes)
                {
                    BsonClassMap.LookupClassMap(cls);
                }

                // AddSceneObject();
                _typesRegistered = true;
            }
        }
Example #2
0
        public ObjectsManager(IDatabaseAgent database, IConnection conn) : base(
                GenerateGuids.GetActorGuid(TYPEACTOR.OBJECTMANAGER), GenerateGuids.GetActorGuid(TYPEACTOR.EMPTY))
        {
            _logger   = LogManager.GetLogger("[Objects Manager]");
            _database = database;
            _conn     = conn;

            _logger.Info("is online");
        }
Example #3
0
        //UNUSED
        public ServerGameObject(IConnection conn, IDatabaseAgent database, string namePrefab) : base(
                GenerateGuids.GetActorGuid(TYPEACTOR.RANDOM), GenerateGuids.GetActorGuid(TYPEACTOR.EMPTY))
        {
            _clients    = new Dictionary <Guid, IGameObjectObserver>();
            _connection = conn;
            _database   = database;


            conn.SpawnGameObject(namePrefab, namePrefab, _localID, _ownerID, Guid.Empty, Guid.Empty, this,
                                 Self.ToString()).Wait();
        }
Example #4
0
        _spawnedObjects;     //todo: move to.... or keep as objects per connection?


        #region ctrors

        public ServerConnection(IDatabaseAgent database) : base(GenerateGuids.GetActorGuid(TYPEACTOR.CONNECTION),
                                                                GenerateGuids.GetActorGuid(TYPEACTOR.EMPTY))
        {
            _allClientObjects = new Dictionary <Guid, Tuple <Guid, IGameObject> >();
            _database         = database;
            _logger           = LogManager.GetLogger("[Connection]");
            _clients          = new Dictionary <Guid, IConnectionObserver>();
            _spawnedObjects   = new Dictionary <Guid, IGameObject>();
            _loadedScenes     = new Dictionary <Guid, ISceneActor>();
            _logger.Info("Server connection initialized");
        }
Example #5
0
        public ServerSceneActor(DatabaseScene dscene, IDatabaseAgent database, IConnection conn)
            : base(dscene.LocalId, GenerateGuids.GetActorGuid(TYPEACTOR.EMPTY))
        {
            _logger     = LogManager.GetLogger($"[Scene: {dscene.ServerName}]");
            _serverName = dscene.ServerName;
            _sceneName  = dscene.SceneName;
            _bundleId   = dscene.BundleId;
            _database   = database;
            _conn       = conn;

            _logger.Info("is online");
        }