/// <summary> /// Creates a new instance of the <see cref="MmoSocial"/> class. /// </summary> /// <param name="server"></param> private MmoSocial(ISocialServer server) { this.server = server; this.sessionCache = new SocialSessionCache(PeerSettings.MaxLockWaitTime); this.worlds = new ConcurrentStorageMap <short, IWorld>(-1); this.primaryFiber = new SerialThreadFiber(ThreadPriority.Highest); this.primaryFiber.Start(); }
/// <summary> /// Creates a new instance of the <see cref="MmoChat"/> class. /// </summary> /// <param name="server"></param> private MmoChat(IChatServer server) { this.server = server; this.channels = new ConcurrentStorageMap <int, Channel>(PeerSettings.MaxLockWaitTime); this.sessionCache = new ChatSessionCache(PeerSettings.MaxLockWaitTime); this.counter = new Counter(INVALID_CHAT_CHANNEL + 1); this.syncFiber = new SerialThreadFiber(ThreadPriority.Highest); this.syncFiber.Start(); }
/// <summary> /// Creates a new instance of the <see cref="SocialServerPeer"/> class /// </summary> /// <param name="initResponse"></param> /// <param name="application"></param> public SocialServerPeer(InitResponse initResponse, SocialApplication application) : base(initResponse, application) { this.application = application; this.messageFiber = new ThreadFiber(new DefaultQueue(), "SocialMessageFiber", true, ThreadPriority.Highest); this.messageFiber.Start(); this.social = MmoSocial.Instantiate(this); // the lock will wait indefinitely this.sessions = new ConcurrentStorageMap <int, ISession>(-1); this.RequestFiber.Enqueue(this.Register); }
/// <summary> /// Creates a new instance of the <see cref="MmoWorld"/> class. /// </summary> /// <param name="server"> The main peer used for communication with other servers and clients. </param> /// <param name="gameConfiguration"> </param> /// <param name="worldDescription"> The world data which contains data of the whole world </param> private MmoWorld(IWorldServer server, GameConfig gameConfiguration, WorldDescription worldDescription) { this.server = server; // world bounds will adjust its size based on the zones this.bounds = new Bounds(Vector3.Zero, Vector3.Zero); this.configuration = gameConfiguration; this.primaryFiber = new SerialThreadFiber(ThreadPriority.Highest); this.primaryFiber.Start(); this.zones = new ConcurrentStorageMap <int, MmoZone>(1000); this.sessionCache = new WorldSessionCache(PeerSettings.MaxLockWaitTime); this.itemCache = new WorldItemCache(); this.LoadWorld(); }
/// <summary> /// Creates a new instance of the <see cref="WorldServerPeer"/> class /// </summary> /// <param name="initResponse"></param> /// <param name="application"></param> public WorldServerPeer(InitResponse initResponse, WorldApplication application) : base(initResponse, application) { this.application = application; this.messageFiber = new ThreadFiber(new DefaultQueue(), "WorldMessageFiber", true, ThreadPriority.Highest); this.messageFiber.Start(); // the lock will wait indefinitely this.sessions = new ConcurrentStorageMap <int, ISession>(-1); this.configuration = GameConfig.Initialize(this.application.BinaryPath); this.world = MmoWorld.Instantiate(this, configuration, new WorldDescription()); this.CreateWorldZones(); this.RequestFiber.Enqueue(this.Register); }
public void Run() { var map = new ConcurrentStorageMap <Guid, string>(-1); var t1 = new Thread(o => { for (var i = 0; i < 10; i++) { map.Add(Guid.NewGuid(), o + i.ToString()); } }); t1.Start("one"); t1.Join(); var t2 = new Thread(o => { for (var i = 0; i < 10; i++) { map.Add(Guid.NewGuid(), o + i.ToString()); } }); t2.Start("two"); t2.Join(); var t3 = new Thread(o => { for (var i = 0; i < 10; i++) { map.Add(Guid.NewGuid(), o + i.ToString()); } }); t3.Start("three"); t3.Join(); foreach (var value in map) { Console.WriteLine(value); } }
/// <summary> /// Creates a new instance of the <see cref="WorldObjectCache"/> class. /// </summary> /// <param name="maxLockMilliseconds"></param> public WorldObjectCache(int maxLockMilliseconds) { this.objects = new ConcurrentStorageMap <byte, int, MmoObject>(maxLockMilliseconds); }