/// <summary> /// 默认配置 /// </summary> /// <param name="config"></param> public override void Configure(IConnectionConfig config) { if (config.HasOption <int>("receiveBufferSize")) { ListenerSocket.ReceiveBufferSize = config.GetOption <int>("receiveBufferSize"); this.BufferSize = ListenerSocket.ReceiveBufferSize; } if (config.HasOption <int>("sendBufferSize")) { ListenerSocket.SendBufferSize = config.GetOption <int>("sendBufferSize"); } if (config.HasOption <bool>("reuseAddress")) { ListenerSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, config.GetOption <bool>("reuseAddress")); } if (config.HasOption <bool>("keepAlive")) { ListenerSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, config.GetOption <bool>("keepAlive")); } if (config.HasOption(OptionKeyEnums.ParseTimeOut.ToString())) { networkState.TimeOutSeconds = Convert.ToInt64(config.GetOption(OptionKeyEnums.ParseTimeOut.ToString())); } }
public override void Configure(IConnectionConfig config) { if (config.HasOption <int>("receiveBufferSize")) { Listener.ReceiveBufferSize = config.GetOption <int>("receiveBufferSize"); } if (config.HasOption <int>("sendBufferSize")) { Listener.SendBufferSize = config.GetOption <int>("sendBufferSize"); } if (config.HasOption <bool>("reuseAddress")) { Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, config.GetOption <bool>("reuseAddress")); } if (config.HasOption <bool>("keepAlive")) { Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, config.GetOption <bool>("keepAlive")); } if (config.HasOption <bool>("proxiesShareFiber")) { ProxiesShareFiber = config.GetOption <bool>("proxiesShareFiber"); } else { ProxiesShareFiber = true; } }
public override void Configure(IConnectionConfig config) { if (config.HasOption<int>("receiveBufferSize")) Listener.ReceiveBufferSize = config.GetOption<int>("receiveBufferSize"); if (config.HasOption<int>("sendBufferSize")) Listener.SendBufferSize = config.GetOption<int>("sendBufferSize"); if (config.HasOption<bool>("reuseAddress")) Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, config.GetOption<bool>("reuseAddress")); if (config.HasOption<int>("backlog")) Backlog = config.GetOption<int>("backlog"); if (config.HasOption<bool>("tcpNoDelay")) Listener.NoDelay = config.GetOption<bool>("tcpNoDelay"); if (config.HasOption<bool>("keepAlive")) Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, config.GetOption<bool>("keepAlive")); if (config.HasOption<bool>("linger") && config.GetOption<bool>("linger")) Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, new LingerOption(true, 10)); else Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); if (config.HasOption<bool>("proxiesShareFiber")) ProxiesShareFiber = config.GetOption<bool>("proxiesShareFiber"); else ProxiesShareFiber = true; }
/// <summary> /// 默认配置 /// </summary> /// <param name="config"></param> public override void Configure(IConnectionConfig config) { if (config.HasOption <int>("ReadBufferSize")) { ListenerSocket.ReadBufferSize = config.GetOption <int>("ReadBufferSize"); } if (config.HasOption <int>("WriteBufferSize")) { ListenerSocket.WriteBufferSize = config.GetOption <int>("WriteBufferSize"); } else { ProxiesShareFiber = true; } }
public override void Configure(IConnectionConfig config) { if (config.HasOption<int>("receiveBufferSize")) Listener.ReceiveBufferSize = config.GetOption<int>("receiveBufferSize"); if (config.HasOption<int>("sendBufferSize")) Listener.SendBufferSize = config.GetOption<int>("sendBufferSize"); if (config.HasOption<bool>("reuseAddress")) Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, config.GetOption<bool>("reuseAddress")); if (config.HasOption<bool>("keepAlive")) Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, config.GetOption<bool>("keepAlive")); if (config.HasOption<bool>("proxiesShareFiber")) ProxiesShareFiber = config.GetOption<bool>("proxiesShareFiber"); else ProxiesShareFiber = true; }
/// <summary> /// 默认配置 /// </summary> /// <param name="config"></param> public override void Configure(IConnectionConfig config) { if (config.HasOption(OptionKeyEnums.ReadBufferSize.ToString())) { ListenerSocket.ReadBufferSize = Convert.ToInt32(config.GetOption(OptionKeyEnums.ReadBufferSize.ToString())); } if (config.HasOption(OptionKeyEnums.WriteBufferSize.ToString())) { ListenerSocket.WriteBufferSize = Convert.ToInt32(config.GetOption(OptionKeyEnums.WriteBufferSize.ToString())); } if (config.HasOption(OptionKeyEnums.ParseTimeOut.ToString())) { networkState.TimeOutSeconds = Convert.ToInt64(config.GetOption(OptionKeyEnums.ParseTimeOut.ToString())); } }
public override void Configure(IConnectionConfig config) { if (config.HasOption <int>("receiveBufferSize")) { ReceiveBufferSize = config.GetOption <int>("receiveBufferSize"); } if (config.HasOption <int>("sendBufferSize")) { SendBufferSize = config.GetOption <int>("sendBufferSize"); } if (config.HasOption <bool>("reuseAddress")) { ReuseAddress = config.GetOption <bool>("reuseAddress"); } if (config.HasOption <bool>("tcpNoDelay")) { NoDelay = config.GetOption <bool>("tcpNoDelay"); } if (config.HasOption <bool>("keepAlive")) { KeepAlive = config.GetOption <bool>("keepAlive"); } if (config.HasOption <bool>("linger") && config.GetOption <bool>("linger")) { Linger = 10; } else { Linger = 0; } if (config.HasOption <TimeSpan>("connectTimeout")) { Timeout = config.GetOption <TimeSpan>("connectTimeout"); } }
public override void Configure(IConnectionConfig config) { if (config.HasOption <int>("receiveBufferSize")) { Client.ReceiveBufferSize = config.GetOption <int>("receiveBufferSize"); } if (config.HasOption <int>("sendBufferSize")) { Client.SendBufferSize = config.GetOption <int>("sendBufferSize"); } if (config.HasOption <bool>("reuseAddress")) { Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, config.GetOption <bool>("reuseAddress")); } if (config.HasOption <bool>("keepAlive")) { Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, config.GetOption <bool>("keepAlive")); } }
public override void Configure(IConnectionConfig config) { if (config.HasOption(OptionKeyEnums.ProtocolTimeOut.ToString())) { int ProtocolTimeOut = (int)config.GetOption(OptionKeyEnums.ProtocolTimeOut.ToString()); if (ProtocolTimeOut > -1 && ProtocolTimeOut < NetworkConstants.BackoffIntervals.Length) { this.Timeout = NetworkConstants.BackoffIntervals[ProtocolTimeOut]; } } }
/// <summary> /// 启动参数设置 /// </summary> /// <param name="connectionConfig"></param> public override void SetupParamOptions(IConnectionConfig connectionConfig) { if (connectionConfig.Options.Count > 0) { SocketParam = new WebSocketParam(); if (connectionConfig.HasOption(WebSocketParamEumns.IsUseCertificate.ToString())) { SocketParam.IsUseCertificate = Convert.ToBoolean(connectionConfig.GetOption(WebSocketParamEumns.IsUseCertificate.ToString())); } else if (connectionConfig.HasOption(WebSocketParamEumns.Port.ToString())) { SocketParam.Port = Convert.ToInt32(connectionConfig.GetOption(WebSocketParamEumns.Port.ToString())); } else if (connectionConfig.HasOption(WebSocketParamEumns.ServerName.ToString())) { SocketParam.ServerName = Convert.ToString(connectionConfig.GetOption(WebSocketParamEumns.ServerName.ToString())); } else if (connectionConfig.HasOption(WebSocketParamEumns.ServerSecurity.ToString())) { SocketParam.ServerSecurity = Convert.ToString(connectionConfig.GetOption(WebSocketParamEumns.ServerSecurity.ToString())); } else if (connectionConfig.HasOption(WebSocketParamEumns.ServerStoreName.ToString())) { SocketParam.ServerStoreName = Convert.ToString(connectionConfig.GetOption(WebSocketParamEumns.ServerStoreName.ToString())); } else if (connectionConfig.HasOption(WebSocketParamEumns.ServerThumbprint.ToString())) { SocketParam.ServerThumbprint = Convert.ToString(connectionConfig.GetOption(WebSocketParamEumns.ServerThumbprint.ToString())); } } }
public override void Configure(IConnectionConfig config) { this.connectionConfig = config; if (config.HasOption(OptionKeyEnums.ProtocolTimeOut.ToString())) { int ProtocolTimeOut = (int)config.GetOption(OptionKeyEnums.ProtocolTimeOut.ToString()); if (ProtocolTimeOut > -1 && ProtocolTimeOut < NetworkConstants.BackoffIntervals.Length) { this.Timeout = NetworkConstants.BackoffIntervals[ProtocolTimeOut]; } } if (config.HasOption(OptionKeyEnums.TaskInterval.ToString())) { this.DefaultTaskInterval = config.GetOption <int>(OptionKeyEnums.TaskInterval.ToString()); this.Sender.Interval = this.DefaultTaskInterval; } if (config.HasOption(OptionKeyEnums.TaskResend.ToString())) { this.DefaultResendCount = config.GetOption <int>(OptionKeyEnums.TaskResend.ToString()); this.Sender.TotalSendTimes = this.DefaultResendCount; } }
/// <summary> /// 创建一个服务端推送 /// </summary> /// <param name="connectionConfig"></param> /// <returns></returns> public IPushBroker <TNotification> NewPushBroker(IConnectionConfig connectionConfig) { var reactor = NewPushBrokerInternal(connectionConfig); reactor.SetupParamOptions(connectionConfig); int Works = 1; if (connectionConfig.HasOption(DefaultConfigTypeEumns.Workers.ToString())) { Works = connectionConfig.GetOption <int>(DefaultConfigTypeEumns.Workers.ToString()); } reactor.DefaultWorks = Works; return(reactor); }
public override void Configure(IConnectionConfig config) { if (config.HasOption <int>("receiveBufferSize")) { Listener.ReceiveBufferSize = config.GetOption <int>("receiveBufferSize"); } if (config.HasOption <int>("sendBufferSize")) { Listener.SendBufferSize = config.GetOption <int>("sendBufferSize"); } if (config.HasOption <bool>("reuseAddress")) { Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, config.GetOption <bool>("reuseAddress")); } if (config.HasOption <int>("backlog")) { Backlog = config.GetOption <int>("backlog"); } if (config.HasOption <bool>("tcpNoDelay")) { Listener.NoDelay = config.GetOption <bool>("tcpNoDelay"); } if (config.HasOption <bool>("keepAlive")) { Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, config.GetOption <bool>("keepAlive")); } if (config.HasOption <bool>("linger") && config.GetOption <bool>("linger")) { Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, new LingerOption(true, 10)); } else { Listener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); } if (config.HasOption <bool>("proxiesShareFiber")) { ProxiesShareFiber = config.GetOption <bool>("proxiesShareFiber"); } else { ProxiesShareFiber = true; } }
public override void Configure(IConnectionConfig config) { if (config.HasOption<int>("receiveBufferSize")) ReceiveBufferSize = config.GetOption<int>("receiveBufferSize"); if (config.HasOption<int>("sendBufferSize")) SendBufferSize = config.GetOption<int>("sendBufferSize"); if (config.HasOption<bool>("reuseAddress")) ReuseAddress = config.GetOption<bool>("reuseAddress"); if (config.HasOption<bool>("tcpNoDelay")) NoDelay = config.GetOption<bool>("tcpNoDelay"); if (config.HasOption<bool>("keepAlive")) KeepAlive = config.GetOption<bool>("keepAlive"); if (config.HasOption<bool>("linger") && config.GetOption<bool>("linger")) Linger = 10; else Linger = 0; if (config.HasOption<TimeSpan>("connectTimeout")) Timeout = config.GetOption<TimeSpan>("connectTimeout"); }
public override void Configure(IConnectionConfig config) { if (config.HasOption<int>("receiveBufferSize")) Client.ReceiveBufferSize = config.GetOption<int>("receiveBufferSize"); if (config.HasOption<int>("sendBufferSize")) Client.SendBufferSize = config.GetOption<int>("sendBufferSize"); if (config.HasOption<bool>("reuseAddress")) Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, config.GetOption<bool>("reuseAddress")); if (config.HasOption<bool>("keepAlive")) Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, config.GetOption<bool>("keepAlive")); }