コード例 #1
0
ファイル: LogonSession.cs プロジェクト: remixod/NetLibClient
        public bool Connect(IPEndPoint ep)
        {
            try
            {
                mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);

                Log.WriteLine(LogType.Normal, "Attempting to connect to Logon Server at {0}:{1}", ep.Address, ep.Port);
                mSocket.Connect(ep);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
                Disconnect();
                return false;
            }

            Log.WriteLine(LogType.Success, "Succesfully connected to Logon Server at {0}:{1}", ep.Address, ep.Port);

            Connected = true;
            pHandler = new PacketHandler(this);
            pLoop = new PacketLoop(this, mSocket);
            pHandler.Initialize();
            return true;
            //Authenticate();
        }
コード例 #2
0
ファイル: WorldSession.cs プロジェクト: remixod/NetLibClient
        public void Connect()
        {
            string[] address = realm.Address.Split(':');
            byte[] test = new byte[1];
            test[0] = 10;
            mCrypt = new PacketCrypt(test);
            IPAddress WSAddr = Dns.GetHostAddresses(address[0])[0];
            IPAddress wWSAddr = Dns.GetHostAddresses(WardenHost)[0];
            int WSPort = Int32.Parse(address[1]);
            IPEndPoint ep = new IPEndPoint(WSAddr, WSPort);
            IPEndPoint wep = new IPEndPoint(wWSAddr, WardenPort);

            try
            {
                mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
                mSocket.Connect(ep);
                Log.WriteLine(netLogic.Shared.LogType.Success, "Successfully connected to WorldServer at: {0}!", realm.Address);

            }
            catch (SocketException ex)
            {
                Log.WriteLine(netLogic.Shared.LogType.Error, "Failed to connect to realm: {0}", ex.Message);
                Disconnect();
                return;
            }

               /* try
            {
                mWardenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
                mWardenSocket.Connect(wep);
            }
            catch (SocketException ex)
            {
                Log.WriteLine(LogType.Error, "Failed to connect to WardenServer: {0}", ex.Message);
                return;
            }*/

            byte[] nullA = new byte[24];
            mCrypt = new PacketCrypt(nullA);
            Connected = true;
            pHandler = new PacketHandler(this);
            pHandler.Initialize();

            pLoop = new PacketLoop(this, mSocket);
            pLoop.Start();
            Thread.Sleep(1000);
        }