/// <summary> /// Connects to the server and performs the initial handshaking /// </summary> public virtual void ConnectToServer() { StartTimeoutPeriod(30); ProxySocketConnector connector = new ProxySocketConnector(parent, Server, Port, Ssl); connector.ConnectionFailed += delegate { DisconnectFromServer(true); }; connector.ConnectionComplete += delegate(object sender, EventArgs e) { this.socket = (sender as ProxySocketConnector).Socket; OnConnectionFinished(); }; connector.BeginConnect(); }
/// <summary> /// Set up the connection to receive data through a stage 1 or stage 3 proxy transfer /// </summary> private void StartReceiveThroughProxy() { ProxySocketConnector connector = new ProxySocketConnector(parent, AOLProxyIP, parent.ServerSettings.LoginPort, Ssl); // okay...? connector.ConnectionFailed += delegate { Logging.WriteString("StartReceiveThroughProxy failed"); OnDirectConnectFailed("Couldn't connect to sender"); }; connector.ConnectionComplete += delegate(object sender, EventArgs e) { this.socket = (sender as ProxySocketConnector).Socket; InitAolProxyReceiveConnectFinished(); }; connector.BeginConnect(); }
/// <summary> /// Sends a Rendezvous INITRECV and begins sending the file through the proxy connection /// </summary> internal void StartSendThroughStage2AolProxy() { ProxySocketConnector connector = new ProxySocketConnector(parent, AOLProxyIP, Port, Ssl); connector.ConnectionFailed += delegate { Logging.WriteString("StartSendThroughStage2Proxy couldn't connect to {0}", AOLProxyIP); DisconnectFromServer(true); }; connector.ConnectionComplete += delegate(object sender, EventArgs e) { this.socket = (sender as ProxySocketConnector).Socket; SendThroughStage2AolProxyConnectFinished(); }; connector.BeginConnect(); }
/// <summary> /// Direct connection to the sender has failed, attempt a proxy redirect /// </summary> private void FallbackToStage2Connection() { directConnectionMethod = DirectConnectionMethod.Proxied; _sequence = RendezvousSequence.Stage2; ProxySocketConnector connector = new ProxySocketConnector(parent, parent.ServerSettings.IcqProxyServer, parent.ServerSettings.LoginPort, Ssl); connector.ConnectionFailed += delegate { Logging.WriteString("FallbackToStage2Connection failed"); DisconnectFromServer(true); }; connector.ConnectionComplete += delegate(object sender, EventArgs e) { this.socket = (sender as ProxySocketConnector).Socket; InitAolProxyConnectFinished(); }; connector.BeginConnect(); }
private void ConnectAsInitiatorProxied() { Server = parent.ServerSettings.IcqProxyServer; Port = parent.ServerSettings.LoginPort; ProxySocketConnector connector = new ProxySocketConnector(parent, Server, Port, Ssl); connector.ConnectionFailed += delegate { Logging.WriteString("ConnectAsInitiatorProxied failed to connect to " + parent.ServerSettings.IcqProxyServer); DisconnectFromServer(true); }; connector.ConnectionComplete += delegate(object sender, EventArgs e) { this.socket = (sender as ProxySocketConnector).Socket; InitAolProxyConnectFinished(); }; connector.BeginConnect(); }
/// <summary> /// Connect to the sender and begin receiving the file /// </summary> /// <remarks>If the direct connection fails at this stage, control is passed to <see cref="FallbackToStage2Connection"/></remarks> private void StartReceiveThroughDirectConnection() { // check for intranet string ipaddress = this.VerifiedIP == ParentSession.Connections.LocalExternalIP.ToString() ? this.ClientIP : this.VerifiedIP; ProxySocketConnector connector = new ProxySocketConnector(parent, ipaddress, Port, Ssl); connector.ConnectionFailed += delegate { Logging.WriteString("StartReceiveThroughDirectConnection couldn't connect, falling back to stage 2"); FallbackToStage2Connection(); }; connector.ConnectionComplete += delegate(object sender, EventArgs e) { this.socket = (sender as ProxySocketConnector).Socket; parent.Messages.RequestDirectConnectionAccept(this); OnDirectConnectReady(); }; connector.BeginConnect(); }