Advertisement
Guest User

Untitled

a guest
Jul 5th, 2011
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 22.73 KB | None | 0 0
  1. Index: agsXMPP2010.csproj
  2. ===================================================================
  3. --- agsXMPP2010.csproj  (revision 127)
  4. +++ agsXMPP2010.csproj  (working copy)
  5. @@ -122,6 +122,7 @@
  6.      <Compile Include="Idn\Stringprep.cs" />
  7.      <Compile Include="Idn\StringprepException.cs" />
  8.      <Compile Include="Net\BoshClientSocket.cs" />
  9. +    <Compile Include="Net\Socks5Socket.cs" />
  10.      <Compile Include="Properties\AssemblyInfo.cs">
  11.        <SubType>Code</SubType>
  12.      </Compile>
  13. Index: Net/BoshClientSocket.cs
  14. ===================================================================
  15. --- Net/BoshClientSocket.cs (revision 127)
  16. +++ Net/BoshClientSocket.cs (working copy)
  17. @@ -433,71 +433,71 @@
  18.              catch (WebException ex)
  19.              {
  20.                  FireOnError(ex);
  21. -                Disconnect();
  22.              }
  23.          }
  24.  
  25.          private void OnGetSessionRequestResponse(IAsyncResult result)
  26.          {
  27. -            // grab the custom state object
  28. -            WebRequestState state = (WebRequestState)result.AsyncState;
  29. -            HttpWebRequest request = (HttpWebRequest)state.WebRequest;
  30. +            try {
  31. +                // grab the custom state object
  32. +                WebRequestState state = (WebRequestState)result.AsyncState;
  33. +                HttpWebRequest request = (HttpWebRequest)state.WebRequest;
  34.  
  35. -            //state.TimeOutTimer.Dispose();
  36. +                //state.TimeOutTimer.Dispose();
  37.  
  38. -            // get the Response
  39. -            HttpWebResponse resp = (HttpWebResponse)request.EndGetResponse(result);
  40. +                // get the Response
  41. +                HttpWebResponse resp = (HttpWebResponse)request.EndGetResponse(result);
  42.  
  43. -            // The server must always return a 200 response code,
  44. -            // sending any session errors as specially-formatted identifiers.
  45. -            if (resp.StatusCode != HttpStatusCode.OK)
  46. -            {
  47. -                //FireOnError(new PollSocketException("unexpected status code " + resp.StatusCode.ToString()));
  48. -                return;
  49. -            }
  50. +                // The server must always return a 200 response code,
  51. +                // sending any session errors as specially-formatted identifiers.
  52. +                if (resp.StatusCode != HttpStatusCode.OK) {
  53. +                    //FireOnError(new PollSocketException("unexpected status code " + resp.StatusCode.ToString()));
  54. +                    return;
  55. +                }
  56.  
  57. -            Stream rs = resp.GetResponseStream();
  58. +                Stream rs = resp.GetResponseStream();
  59.  
  60. -            int readlen;
  61. -            byte[] readbuf = new byte[1024];
  62. -            MemoryStream ms = new MemoryStream();
  63. -            while ((readlen = rs.Read(readbuf, 0, readbuf.Length)) > 0)
  64. -            {
  65. -                ms.Write(readbuf, 0, readlen);
  66. -            }
  67. +                int readlen;
  68. +                byte[] readbuf = new byte[1024];
  69. +                MemoryStream ms = new MemoryStream();
  70. +                while ((readlen = rs.Read(readbuf, 0, readbuf.Length)) > 0) {
  71. +                    ms.Write(readbuf, 0, readlen);
  72. +                }
  73.  
  74. -            byte[] recv = ms.ToArray();
  75. +                byte[] recv = ms.ToArray();
  76.  
  77. -            if (recv.Length > 0)
  78. -            {
  79. -                string body = null;
  80. -                string stanzas = null;
  81. +                if (recv.Length > 0) {
  82. +                    string body = null;
  83. +                    string stanzas = null;
  84.  
  85. -                string res = Encoding.UTF8.GetString(recv, 0, recv.Length);
  86. +                    string res = Encoding.UTF8.GetString(recv, 0, recv.Length);
  87.  
  88. -                ParseResponse(res, ref body, ref stanzas);
  89. -              
  90. -                Document doc = new Document();
  91. -                doc.LoadXml(body);
  92. -                Body boshBody = doc.RootElement as Body;
  93. +                    ParseResponse(res, ref body, ref stanzas);
  94.  
  95. -                sid         = boshBody.Sid;
  96. -                polling     = boshBody.Polling;
  97. -                m_MaxPause  = boshBody.MaxPause;
  98. +                    Document doc = new Document();
  99. +                    doc.LoadXml(body);
  100. +                    Body boshBody = doc.RootElement as Body;
  101.  
  102. -                byte[] bin = Encoding.UTF8.GetBytes(DummyStreamHeader + stanzas);
  103. -                
  104. -                base.FireOnReceive(bin, bin.Length);
  105. +                    sid = boshBody.Sid;
  106. +                    polling = boshBody.Polling;
  107. +                    m_MaxPause = boshBody.MaxPause;
  108.  
  109. -                // cleanup webrequest resources
  110. -                ms.Close();
  111. -                rs.Close();
  112. -                resp.Close();
  113. +                    byte[] bin = Encoding.UTF8.GetBytes(DummyStreamHeader + stanzas);
  114.  
  115. -                activeRequests--;
  116. +                    base.FireOnReceive(bin, bin.Length);
  117.  
  118. -                if (activeRequests == 0)
  119. -                    StartWebRequest();                
  120. +                    // cleanup webrequest resources
  121. +                    ms.Close();
  122. +                    rs.Close();
  123. +                    resp.Close();
  124. +
  125. +                    activeRequests--;
  126. +
  127. +                    if (activeRequests == 0)
  128. +                        StartWebRequest();
  129. +                }
  130. +            } catch (Exception ex) {
  131. +                FireOnError(ex);
  132.              }
  133.          }
  134.  
  135. Index: Net/ClientSocket.cs
  136. ===================================================================
  137. --- Net/ClientSocket.cs (revision 127)
  138. +++ Net/ClientSocket.cs (working copy)
  139. @@ -58,18 +58,18 @@
  140.      /// </summary>
  141.      public class ClientSocket : BaseSocket
  142.      {
  143. -        Socket _socket;
  144. +        protected Socket _socket;
  145.  #if SSL   
  146.          SslStream           m_SSLStream;
  147.  #endif
  148. -        NetworkStream m_Stream;
  149. -        Stream m_NetworkStream = null;
  150. +        protected NetworkStream m_Stream;
  151. +        protected Stream m_NetworkStream = null;
  152.  
  153.  
  154. -        const int BUFFERSIZE = 1024;
  155. -        private byte[] m_ReadBuffer = null;
  156. +        protected const int BUFFERSIZE = 1024;
  157. +        protected byte[] m_ReadBuffer = null;
  158.  
  159. -        private bool m_SSL = false;
  160. +        protected bool m_SSL = false;
  161.  
  162.          private bool m_PendingSend = false;
  163.          private Queue m_SendQueue = new Queue();
  164. @@ -77,9 +77,9 @@
  165.          /// <summary>
  166.          /// is compression used for this connection
  167.          /// </summary>
  168. -        private bool m_Compressed = false;
  169. +        protected bool m_Compressed = false;
  170.  
  171. -        private bool m_ConnectTimedOut = false;
  172. +        protected bool m_ConnectTimedOut = false;
  173.          /// <summary>
  174.          /// is used to compress data
  175.          /// </summary>
  176. @@ -89,7 +89,7 @@
  177.          /// </summary>
  178.          private Inflater inflater = null;
  179.  
  180. -        private Timer connectTimeoutTimer;
  181. +        protected Timer connectTimeoutTimer;
  182.  
  183.  
  184.          #region << Constructor >>
  185. @@ -221,7 +221,7 @@
  186.              }
  187.          }
  188.  
  189. -        private void EndConnect(IAsyncResult ar)
  190. +        protected void EndConnect(IAsyncResult ar)
  191.          {
  192.              if (m_ConnectTimedOut)
  193.              {
  194. @@ -262,7 +262,7 @@
  195.          /// Connect Timeout Timer Callback
  196.          /// </summary>
  197.          /// <param name="stateInfo"></param>
  198. -        private void connectTimeoutTimerDelegate(Object stateInfo)
  199. +        protected void connectTimeoutTimerDelegate(Object stateInfo)
  200.          {
  201.              connectTimeoutTimer.Dispose();
  202.              m_ConnectTimedOut = true;
  203. @@ -284,7 +284,7 @@
  204.         /// <summary>
  205.         ///
  206.         /// </summary>
  207. -       private void InitSSL()
  208. +        protected void InitSSL()
  209.         {
  210.              InitSSL(SslProtocols.Default);
  211.         }        
  212. @@ -293,7 +293,7 @@
  213.         ///
  214.         /// </summary>
  215.         /// <param name="protocol"></param>    
  216. -        private void InitSSL(SslProtocols protocol)
  217. +        protected void InitSSL(SslProtocols protocol)
  218.         {            
  219.             m_SSLStream = new SslStream(
  220.                  m_Stream,
  221. @@ -533,7 +533,7 @@
  222.          /// <summary>
  223.          /// Read data from server.
  224.          /// </summary>
  225. -        private void Receive()
  226. +        protected void Receive()
  227.          {
  228.              m_NetworkStream.BeginRead(m_ReadBuffer, 0, BUFFERSIZE, new AsyncCallback(EndReceive), null);
  229.          }
  230. Index: Net/SocketConnectionType.cs
  231. ===================================================================
  232. --- Net/SocketConnectionType.cs (revision 127)
  233. +++ Net/SocketConnectionType.cs (working copy)
  234. @@ -43,6 +43,11 @@
  235.          /// <para>XEP-0124: Bidirectional-streams Over Synchronous HTTP (BOSH)</para>
  236.          /// <para>http://www.xmpp.org/extensions/xep-0124.html</para>
  237.          /// </summary>
  238. -        Bosh
  239. +        Bosh,
  240. +
  241. +        /// <summary>
  242. +        /// <para>SOCKS5 proxy</para>
  243. +        /// </summary>
  244. +        SOCKS5
  245.     }
  246.  }
  247. Index: Net/Socks5Socket.cs
  248. ===================================================================
  249. --- Net/Socks5Socket.cs (revision 0)
  250. +++ Net/Socks5Socket.cs (revision 0)
  251. @@ -0,0 +1,300 @@
  252. +п»їusing System;
  253. +using System.Net;
  254. +using System.Net.Sockets;
  255. +using System.Threading;
  256. +using System.IO;
  257. +using System.Text;
  258. +using System.Configuration;
  259. +using System.Collections;
  260. +using System.Diagnostics;
  261. +
  262. +#if SSL
  263. +using System.Net.Security;
  264. +using System.Security.Authentication;
  265. +using System.Security.Cryptography.X509Certificates;
  266. +#endif
  267. +
  268. +#if BCCRYPTO
  269. +using Org.BouncyCastle.Crypto.Tls;
  270. +#endif
  271. +
  272. +using agsXMPP.IO.Compression;
  273. +
  274. +using agsXMPP;
  275. +
  276. +namespace agsXMPP.Net {
  277. +    /// <summary>
  278. +    /// Socks5 error codes
  279. +    /// </summary>
  280. +    public enum ErrorCode {
  281. +        NO_AUTH_METHODS,
  282. +        BAD_AUTH,
  283. +        GENERAL_FAILURE,
  284. +        CONNECTION_DIBALED,
  285. +        NETWORK_UNREACHABLE,
  286. +        HOST_UNREACHABLE,
  287. +        CONENCTION_FAILED,
  288. +        TTL_EXCEEDED,
  289. +        NOT_SUPPORTED,
  290. +        ADDR_TYPE_NOT_SUPPORTED,
  291. +        CONNECTION_TIMEDOUT
  292. +    };
  293. +    /// <summary>
  294. +    /// Provides sock5 error handling
  295. +    /// </summary>
  296. +    public class Socks5Exception : Exception {
  297. +        private static string[] ErrorStrings = new string[] {
  298. +            "None of the authentication method was accepted by proxy server",
  299. +            "Bad Usernaem/Password",
  300. +            "General server failure",
  301. +            "Connection disabled by rule",
  302. +            "Network unreachable",
  303. +            "Host unreachable",
  304. +            "Connection failed",
  305. +            "TTL exceeded",
  306. +            "Commandnot supported or protocol error",
  307. +            "Address type not supported",
  308. +            "Connection timed out"
  309. +        };
  310. +        public ErrorCode Socks5Error;
  311. +        public Socks5Exception ( ErrorCode err ) : base (ErrorStrings[(int)err]) {
  312. +            Socks5Error = err;
  313. +        }
  314. +    }
  315. +    /// <summary>
  316. +    /// Provides sock5 functionality to clients
  317. +    /// </summary>
  318. +    public class Socks5Socket : ClientSocket {
  319. +        public string socks5host = null;
  320. +        public string socks5user = "";
  321. +        public string socks5pass = "";
  322. +        public ushort socks5port = 1080;
  323. +
  324. +        /// <summary>
  325. +        /// Read and analize last server response
  326. +        /// </summary>
  327. +        private byte GetSocks5Response() {
  328. +            byte[] response = new byte[257];
  329. +            // version
  330. +            _socket.Receive(response, 1, SocketFlags.None); // 1
  331. +            if (response[0] == 0x05) {
  332. +                // read response code
  333. +                _socket.Receive(response, 1, SocketFlags.None); // 2
  334. +                byte retcode = response[0];
  335. +                // reserved
  336. +                _socket.Receive(response, 1, SocketFlags.None);
  337. +                // connect host data
  338. +                _socket.Receive(response, 1, SocketFlags.None);
  339. +                switch (response[0]) {
  340. +                    case 0x01:
  341. +                        // ipv4 address
  342. +                        _socket.Receive(response, 4, SocketFlags.None);
  343. +                        break;
  344. +                    case 0x04:
  345. +                        // ipv6 address
  346. +                        _socket.Receive(response, 16, SocketFlags.None);
  347. +                        break;
  348. +                    case 0x03:
  349. +                        // host len
  350. +                        _socket.Receive(response, 1, SocketFlags.None);
  351. +                        // host
  352. +                        _socket.Receive(response, response[0], SocketFlags.None);
  353. +                        break;
  354. +                    default:
  355. +                        // unknown value
  356. +                        retcode = 0x01;
  357. +                        break;
  358. +                }
  359. +                // port
  360. +                _socket.Receive(response, 2, SocketFlags.None);
  361. +                // return result
  362. +                return retcode;
  363. +            } else {
  364. +                return 0x01;
  365. +            }
  366. +        }
  367. +
  368. +        /// <summary>
  369. +        /// Initialize byte array with 0x00
  370. +        /// </summary>
  371. +        private void Clear(ref byte[] arr) {
  372. +            for (int a = 0; a < arr.Length; a++) {
  373. +                arr[a] = 0x00;
  374. +            }
  375. +        }
  376. +
  377. +        /// <summary>
  378. +        /// Connect to socks5 proxy using specified settings
  379. +        /// </summary>
  380. +        private void ConnectToSocks5Proxy() {
  381. +            byte[] request = new byte[257];
  382. +            byte[] response = new byte[257];
  383. +            byte[] rawBytes = null;
  384. +            ushort nIndex;
  385. +
  386. +            nIndex = 0;
  387. +            // Version 5
  388. +            request[nIndex++] = 0x05;
  389. +            // One authentication methods are in packet...
  390. +            request[nIndex++] = 0x01;
  391. +            if (socks5user.Length != 0 || socks5pass.Length != 0) {
  392. +                // username and password auth
  393. +                request[nIndex++] = 0x02;
  394. +            } else {
  395. +                // no auth
  396. +                request[nIndex++] = 0x00;
  397. +            }
  398. +            // Send the authentication negotiation request...
  399. +            _socket.Send(request, nIndex, SocketFlags.None);
  400. +
  401. +            // Receive 2 byte response...
  402. +            Clear(ref response);
  403. +            _socket.Receive(response, 2, SocketFlags.None);
  404. +            if (response[1] == 0xFF) {
  405. +                // No authentication method was accepted close the socket.
  406. +                throw new Socks5Exception(ErrorCode.NO_AUTH_METHODS);
  407. +            }
  408. +
  409. +            // server selected Username/Password Authentication protocol
  410. +            if (response[1] == 0x02) {
  411. +                nIndex = 0;
  412. +                // Version 5
  413. +                request[nIndex++] = 0x05;
  414. +                // add user name
  415. +                request[nIndex++] = (byte)socks5user.Length;
  416. +                rawBytes = Encoding.Default.GetBytes(socks5user);
  417. +                rawBytes.CopyTo(request, nIndex);
  418. +                nIndex += (ushort)rawBytes.Length;
  419. +                // add password
  420. +                request[nIndex++] = (byte)socks5pass.Length;
  421. +                rawBytes = Encoding.Default.GetBytes(socks5pass);
  422. +                rawBytes.CopyTo(request, nIndex);
  423. +                nIndex += (ushort)rawBytes.Length;
  424. +                // Send the Username/Password request
  425. +                _socket.Send(request, nIndex, SocketFlags.None);
  426. +                // Receive 2 byte response
  427. +                Clear(ref response);
  428. +                _socket.Receive(response, 2, SocketFlags.None);
  429. +                if (response[1] != 0x00) {
  430. +                    throw new Socks5Exception(ErrorCode.BAD_AUTH);
  431. +                }
  432. +            }
  433. +
  434. +            // Send connect request
  435. +            nIndex = 0;
  436. +            // version 5.
  437. +            request[nIndex++] = 0x05;
  438. +            // command = connect.
  439. +            request[nIndex++] = 0x01;
  440. +            // Reserve = must be 0x00
  441. +            request[nIndex++] = 0x00;
  442. +
  443. +            // Address is full-qualified domain name.
  444. +            request[nIndex++] = 0x03;
  445. +            // length of address.
  446. +            request[nIndex++] = Convert.ToByte(socks5host.Length);
  447. +            rawBytes = Encoding.Default.GetBytes(socks5host);
  448. +            rawBytes.CopyTo(request, nIndex);
  449. +            nIndex += (ushort)rawBytes.Length;
  450. +
  451. +            // using big-edian byte order
  452. +            byte[] portBytes = BitConverter.GetBytes(socks5port);
  453. +            for (int i = portBytes.Length - 1; i >= 0; i--) {
  454. +                request[nIndex++] = portBytes[i];
  455. +            }
  456. +
  457. +            // send connect request.
  458. +            _socket.Send(request, nIndex, SocketFlags.None);
  459. +            byte retcode = GetSocks5Response();
  460. +            // Get variable length response
  461. +            switch (retcode) {
  462. +                case 0x00:
  463. +                    // connected
  464. +                    break;
  465. +                case 0x01:
  466. +                    throw new Socks5Exception(ErrorCode.GENERAL_FAILURE);
  467. +                case 0x02:
  468. +                    throw new Socks5Exception(ErrorCode.CONNECTION_DIBALED);
  469. +                case 0x03:
  470. +                    throw new Socks5Exception(ErrorCode.NETWORK_UNREACHABLE);
  471. +                case 0x04:
  472. +                    throw new Socks5Exception(ErrorCode.HOST_UNREACHABLE);
  473. +                case 0x05:
  474. +                    throw new Socks5Exception(ErrorCode.CONENCTION_FAILED);
  475. +                case 0x06:
  476. +                    throw new Socks5Exception(ErrorCode.TTL_EXCEEDED);
  477. +                case 0x07:
  478. +                    throw new Socks5Exception(ErrorCode.NOT_SUPPORTED);
  479. +                case 0x08:
  480. +                    throw new Socks5Exception(ErrorCode.ADDR_TYPE_NOT_SUPPORTED);
  481. +            }
  482. +        }
  483. +
  484. +        public override void Connect() {
  485. +            // Socket is never compressed at startup
  486. +            m_Compressed = false;
  487. +            m_ReadBuffer = null;
  488. +            m_ReadBuffer = new byte[BUFFERSIZE];
  489. +
  490. +            try {
  491. +                IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry(Address);
  492. +                IPAddress ipAddress = null;
  493. +                if (ipHostInfo.AddressList.Length > 0) {
  494. +                    ipAddress = ipHostInfo.AddressList[0];
  495. +                } else {
  496. +                    ipAddress = IPAddress.Parse(Address);
  497. +                }
  498. +                IPEndPoint endPoint = new IPEndPoint(ipAddress, Port);
  499. +                // Timeout
  500. +                // .NET supports no timeout for connect, and the default timeout is very high, so it could
  501. +                // take very long to establish the connection with the default timeout. So we handle custom
  502. +                // connect timeouts with a timer
  503. +                m_ConnectTimedOut = false;
  504. +                TimerCallback timerDelegate = new TimerCallback(connectTimeoutTimerDelegate);
  505. +                connectTimeoutTimer = new Timer(timerDelegate, null, ConnectTimeout, ConnectTimeout);
  506. +#if !(CF || CF_2)
  507. +                // IPV6 Support for .NET 2.0
  508. +                if (Socket.OSSupportsIPv6 && (endPoint.AddressFamily == AddressFamily.InterNetworkV6)) {
  509. +                    _socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
  510. +                } else {
  511. +                    _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  512. +                }
  513. +#else
  514. +                // CF, there is no IPV6 support yet
  515. +                _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  516. +#endif
  517. +                _socket.BeginConnect(endPoint, new AsyncCallback(EndConnect), null);
  518. +            } catch (Exception ex) {
  519. +                base.FireOnError(ex);
  520. +            }
  521. +        }
  522. +
  523. +        new protected void EndConnect(IAsyncResult ar) {
  524. +            // go do something
  525. +            if (m_ConnectTimedOut) {
  526. +                FireOnError(new Socks5Exception(ErrorCode.CONNECTION_TIMEDOUT));
  527. +            } else {
  528. +                try {
  529. +                    // stop the timeout timer
  530. +                    connectTimeoutTimer.Dispose();
  531. +                    // pass connection status with event
  532. +                    _socket.EndConnect(ar);
  533. +                    // try socks5 auth
  534. +                    ConnectToSocks5Proxy();
  535. +                    // assing network stream as usual
  536. +                    m_Stream = new NetworkStream(_socket, false);
  537. +                    m_NetworkStream = m_Stream;
  538. +#if SSL
  539. +                    if (m_SSL)
  540. +                        InitSSL();
  541. +#endif
  542. +                    FireOnConnect();
  543. +                    // Setup Receive Callback
  544. +                    Receive();
  545. +                } catch (Exception ex) {
  546. +                    FireOnError(ex);
  547. +                }
  548. +            }
  549. +        }
  550. +    }
  551. +}
  552. Index: XmppClientConnection.cs
  553. ===================================================================
  554. --- XmppClientConnection.cs (revision 127)
  555. +++ XmppClientConnection.cs (working copy)
  556. @@ -742,8 +742,12 @@
  557.  
  558.             StreamParser.Reset();
  559.  #if SSL
  560. -           if (ClientSocket.GetType() == typeof(ClientSocket))
  561. -               ((ClientSocket) ClientSocket).SSL = m_UseSSL;
  562. +            if (ClientSocket.GetType() == typeof(Socks5Socket)) {
  563. +                ((Socks5Socket)ClientSocket).SSL = m_UseSSL;
  564. +            }
  565. +            if (ClientSocket.GetType() == typeof(ClientSocket)) {
  566. +                ((ClientSocket)ClientSocket).SSL = m_UseSSL;
  567. +            }
  568.  #endif    
  569.              // this should start later
  570.              //if (m_KeepAlive)
  571. Index: XmppConnection.cs
  572. ===================================================================
  573. --- XmppConnection.cs   (revision 127)
  574. +++ XmppConnection.cs   (working copy)
  575. @@ -328,12 +328,23 @@
  576.             m_ClientSocket = null;
  577.  
  578.             // Socket Stuff
  579. -           if (m_SocketConnectionType == agsXMPP.Net.SocketConnectionType.HttpPolling)
  580. -               m_ClientSocket= new PollClientSocket();            
  581. -            else if (m_SocketConnectionType == agsXMPP.Net.SocketConnectionType.Bosh)
  582. -                m_ClientSocket = new BoshClientSocket(this);
  583. -            else
  584. -                m_ClientSocket = new ClientSocket();
  585. +            switch (m_SocketConnectionType) {
  586. +                case Net.SocketConnectionType.Direct:
  587. +                    m_ClientSocket = new ClientSocket();
  588. +                    break;
  589. +                case Net.SocketConnectionType.HttpPolling:
  590. +                    m_ClientSocket= new PollClientSocket();
  591. +                    break;
  592. +                case Net.SocketConnectionType.Bosh:
  593. +                    m_ClientSocket = new BoshClientSocket(this);
  594. +                    break;
  595. +                case Net.SocketConnectionType.SOCKS5:
  596. +                    m_ClientSocket = new Socks5Socket();
  597. +                    break;
  598. +                default:
  599. +                    FireOnError ( this, new Exception( "Can not determine connection type" ));
  600. +                    break;
  601. +            }
  602.        
  603.             m_ClientSocket.OnConnect    += new ObjectHandler(SocketOnConnect);
  604.             m_ClientSocket.OnDisconnect += new ObjectHandler(SocketOnDisconnect);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement