protected TcpTransportBase(string host, int port, MTProtoTransportType mtProtoType, TLProxyConfig proxyConfig) { MessageIdDict = new Dictionary <long, long>(); Host = host; Port = port; MTProtoType = mtProtoType; ProxyConfig = proxyConfig; var random = new Random(); Id = random.Next(0, 255); _timer = new Timer(OnTimerTick, _timer, Timeout.Infinite, Timeout.Infinite); }
public TLProxyConfig GetProxyConfig() { return(new TLProxyConfig { Server = SettingsHelper.ProxyServer, Port = SettingsHelper.ProxyPort, Username = SettingsHelper.ProxyUsername, Password = SettingsHelper.ProxyPassword, IsEnabled = SettingsHelper.IsProxyEnabled }); if (_proxyConfig != null) { return(_proxyConfig); } _proxyConfig = TLUtils.OpenObjectFromMTProtoFile <TLProxyConfig>(_proxyConfigSyncRoot, Constants.ProxyConfigFileName) ?? TLProxyConfig.Empty; return(_proxyConfig); }
public TcpTransport(string host, int port, MTProtoTransportType mtProtoType, TLProxyConfig proxyConfig) : base(host, port, mtProtoType, proxyConfig) { // ipv6 support _address = IPAddress.Parse(host); //var addressFamily = AddressFamily.InterNetwork; //if (IPAddress.TryParse(host, out _address)) //{ // if (_address.AddressFamily == AddressFamily.InterNetworkV6) // { // addressFamily = AddressFamily.InterNetworkV6; // } //} _socket = new Socket(_address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _buffer = new byte[BufferSize]; _listener.SetBuffer(_buffer, 0, _buffer.Length); _listener.Completed += OnReceived; }
public void SetProxyConfig(TLProxyConfig proxyConfig) { _proxyConfig = proxyConfig; TLUtils.SaveObjectToMTProtoFile(_proxyConfigSyncRoot, Constants.ProxyConfigFileName, _proxyConfig); }
public TcpTransportWinRT(string host, int port, MTProtoTransportType mtProtoType, TLProxyConfig proxyConfig) : base(host, port, mtProtoType, proxyConfig) { _timeout = 25.0; _socket = new StreamSocket(); var control = _socket.Control; control.QualityOfService = SocketQualityOfService.LowLatency; _dataReader = new DataReader(_socket.InputStream) { InputStreamOptions = InputStreamOptions.Partial }; _dataWriter = new DataWriter(_socket.OutputStream); //lock (_dataWriterSyncRoot) //{ // var buffer = GetInitBufferInternal(); // _dataWriter.WriteBytes(buffer); //} }