Ejemplo n.º 1
0
        /// <summary>
        ///     Creates a new DarkRiftClient object with specified cache settings.
        /// </summary>
        /// <param name="objectCacheSettings">The settings for the object cache.</param>
        public DarkRiftClient(ClientObjectCacheSettings objectCacheSettings)
        {
            ObjectCache.Initialize(objectCacheSettings);
            ClientObjectCache.Initialize(objectCacheSettings);

            this.RoundTripTime = new RoundTripTimeHelper(10, 10);
        }
        /// <summary>
        ///     Creates a new args object for the <see cref="DarkRiftClient.MessageReceived"/> event.
        /// </summary>
        /// <param name="message">The message received.</param>
        /// <param name="sendMode">The send mode the message was received with.</param>
        public static MessageReceivedEventArgs Create(Message message, SendMode sendMode)
        {
            MessageReceivedEventArgs messageReceivedEventArgs = ClientObjectCache.GetMessageReceivedEventArgs();

            messageReceivedEventArgs.message  = message;
            messageReceivedEventArgs.SendMode = sendMode;

            messageReceivedEventArgs.isCurrentlyLoungingInAPool = false;

            return(messageReceivedEventArgs);
        }
Ejemplo n.º 3
0
        public DarkRiftClient(ObjectCacheSettings objectCacheSettings)
        {
            ObjectCache.Initialize(objectCacheSettings);

            if (objectCacheSettings is ClientObjectCacheSettings settings)
            {
                ClientObjectCache.Initialize(settings);
            }
            else
            {
                ClientObjectCacheSettings clientObjectCacheSettings = new ClientObjectCacheSettings {
                    MaxMessageReceivedEventArgs = 4
                };
                ClientObjectCache.Initialize(clientObjectCacheSettings);
            }

            this.RoundTripTime = new RoundTripTimeHelper(10, 10);
        }
 /// <summary>
 ///     Recycles this object back into the pool.
 /// </summary>
 public void Dispose()
 {
     ClientObjectCache.ReturnMessageReceivedEventArgs(this);
     isCurrentlyLoungingInAPool = true;
 }
 /// <summary>
 ///     Initializes the object cache.
 /// </summary>
 /// <remarks>
 ///     Normally, initializing the object cache is handled for you when you create a server or client
 ///     however there are times when it is necessary to initialize it without creating a server or client
 ///     such as during testing. This method can be used to initialize the cache in those circumstances.
 ///
 ///     If the cache is already initialized this method will do nothing.
 ///
 ///     This method will also initialize the <see cref="ObjectCache"/>.
 /// </remarks>
 /// <param name="settings"></param>
 //DR3 Make static
 public void InitializeObjectCache(ClientObjectCacheSettings settings)
 {
     ObjectCache.Initialize(settings);
     ClientObjectCache.Initialize(settings);
 }