public void LoadSettings(RelayNodeDefinition node, RelayNodeGroupDefinition group)
		{
			MySpace.SocketTransport.SocketSettings newSettings = BuildSettings(group.SocketSettings);
			if (newSettings.SameAs(settings)) return;
			IDisposable disposableObject = null;
			try
			{
				settings = newSettings;
				socketClient = new SocketClient(node.IPEndPoint, settings);
				disposableObject = asyncSocketClient;
				asyncSocketClient = new AsyncSocketClient(node.IPEndPoint, new SocketPoolConfig
				{
					ReceiveTimeout = settings.ReceiveTimeout,
					NetworkOrdered = settings.UseNetworkOrder,
					ConnectTimeout = settings.ConnectTimeout,
					LoanCapacity = settings.PoolSize
				});
			}
			finally
			{
				if (disposableObject != null)
				{
					try
					{
						asyncSocketClient.Dispose();
					}
					catch (Exception ex)
					{
						log.Error("Failed to dispose AsyncSocketClient", ex);
					}
				}
			}
		}
        public void LoadSettings(RelayNodeDefinition node, RelayNodeGroupDefinition group)
        {
            MySpace.SocketTransport.SocketSettings newSettings = BuildSettings(group.SocketSettings);
            if (newSettings.SameAs(settings))
            {
                return;
            }
            IDisposable disposableObject = null;

            try
            {
                settings          = newSettings;
                socketClient      = new SocketClient(node.IPEndPoint, settings);
                disposableObject  = asyncSocketClient;
                asyncSocketClient = new AsyncSocketClient(node.IPEndPoint, new SocketPoolConfig
                {
                    ReceiveTimeout = settings.ReceiveTimeout,
                    NetworkOrdered = settings.UseNetworkOrder,
                    ConnectTimeout = settings.ConnectTimeout,
                    LoanCapacity   = settings.PoolSize
                });
            }
            finally
            {
                if (disposableObject != null)
                {
                    try
                    {
                        asyncSocketClient.Dispose();
                    }
                    catch (Exception ex)
                    {
                        log.Error("Failed to dispose AsyncSocketClient", ex);
                    }
                }
            }
        }
        private static MySpace.SocketTransport.SocketSettings BuildSettings(Common.Schemas.SocketSettings socketSettings)
        {
            MySpace.SocketTransport.SocketSettings settings = SocketClient.GetDefaultSettings();
            if (socketSettings != null)
            {
                if (socketSettings.ConnectTimeout > 0)
                {
                    settings.ConnectTimeout = socketSettings.ConnectTimeout;
                }
                if (socketSettings.MaximumMessageSize > 0)
                {
                    settings.MaximumReplyMessageSize = socketSettings.MaximumMessageSize;
                }
                if (socketSettings.ReceiveBufferSize > 0)
                {
                    settings.ReceiveBufferSize = socketSettings.ReceiveBufferSize;
                }
                if (socketSettings.ReceiveTimeout > 0)
                {
                    settings.ReceiveTimeout = socketSettings.ReceiveTimeout;
                }
                if (socketSettings.SendBufferSize > 0)
                {
                    settings.SendBufferSize = socketSettings.SendBufferSize;
                }
                if (socketSettings.SendTimeout > 0)
                {
                    settings.SendTimeout = socketSettings.SendTimeout;
                }
                if (socketSettings.PoolSize > 0)
                {
                    settings.PoolSize = socketSettings.PoolSize;
                }
            }

            return(settings);
        }
Esempio n. 4
0
 /// <summary>
 /// Create a new SocketClient with a default connection to destination, using the supplied settings.
 /// </summary>
 public SocketClient(IPEndPoint destination, SocketSettings settings)
 {
     mySettings    = settings;
     mySocketPools = SocketManager.Instance.GetSocketPools(settings);
     mySocketPool  = SocketManager.Instance.GetSocketPool(destination, settings);
 }
Esempio n. 5
0
 internal SocketClientConfig(SocketSettings defaultSettings)
 {
     DefaultSocketSettings = defaultSettings;
 }
Esempio n. 6
0
 /// <summary>
 /// Create a new SocketClient that will use the supplied settings for all messages.
 /// </summary>
 /// <param name="settings"></param>
 public SocketClient(SocketSettings settings)
 {
     mySettings    = settings;
     mySocketPools = SocketManager.Instance.GetSocketPools(settings);
 }
Esempio n. 7
0
 /// <summary>
 /// Get the number of sockets created and in use for a given destination and settings combination.
 /// </summary>
 /// <param name="destination">The server endpoint to check for.</param>
 /// <param name="settings">The settings object portion of the pool key.</param>
 /// <param name="totalSockets">The number of sockets created.</param>
 /// <param name="activeSockets">The number of active sockets.</param>
 public void GetSocketCounts(IPEndPoint destination, SocketSettings settings, out int totalSockets, out int activeSockets)
 {
     SocketManager.Instance.GetSocketCounts(destination, settings, out totalSockets, out activeSockets);
 }
 internal ArraySocketPool(IPEndPoint destination, SocketSettings settings)
     : base(destination, settings)
 {
     sockets = new ArrayManagedSocket[this.poolSize];
 }
 internal ArrayManagedSocket(SocketSettings settings, SocketPool pool, int index)
     : base(settings, pool)
 {
     this.Index = index;
 }
 internal LinkedManagedSocket(SocketSettings settings, SocketPool pool)
     : base(settings, pool)
 {
 }