Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerSockets"/> class.
        /// </summary>
        /// <param name="server">The <see cref="Server"/> instance.</param>
        public ServerSockets(Server server) : base(CommonConfig.NetworkAppIdentifier, CommonConfig.ServerPort)
        {
            _packetHandler = new ServerPacketHandler(server);

            // When debugging, use the StatMessageProcessorManager instead (same thing as the other, but provides network statistics)
#if DEBUG
            var m = new StatMessageProcessorManager(_packetHandler, EnumHelper<ClientPacketID>.BitsRequired);
            m.Stats.EnableFileOutput(ContentPaths.Build.Root.Join("netstats_in" + EngineSettings.DataFileSuffix));
            _messageProcessorManager = m;
#else
            _messageProcessorManager = new MessageProcessorManager(_packetHandler, EnumHelper<ClientPacketID>.BitsRequired);
#endif
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientSockets"/> class.
        /// </summary>
        /// <param name="screenManager">The <see cref="IScreenManager"/> instance.</param>
        /// <exception cref="MethodAccessException">An instance of this object has already been created.</exception>
        ClientSockets(IScreenManager screenManager) : base(CommonConfig.NetworkAppIdentifier)
        {
            if (_instance != null)
                throw new MethodAccessException("ClientSockets instance was already created. Use that instead.");

            _screenManager = screenManager;
            _packetHandler = new ClientPacketHandler(this, ScreenManager, DynamicEntityFactory.Instance);

            // When debugging, use the StatMessageProcessorManager instead (same thing as the other, but provides network statistics)
#if DEBUG
            var m = new StatMessageProcessorManager(_packetHandler, EnumHelper<ServerPacketID>.BitsRequired);
            m.Stats.EnableFileOutput(ContentPaths.Build.Root.Join("netstats_in" + EngineSettings.DataFileSuffix));
            _messageProcessorManager = m;
#else
            _messageProcessorManager = new MessageProcessorManager(_packetHandler, EnumHelper<ServerPacketID>.BitsRequired);
#endif
        }