public bool Connect()
        {
            if (Sock != null)
            {
                Disconnect();
            }
            Sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress  host = IPAddress.Parse(sIP);
            IPEndPoint ipep = new IPEndPoint(host, iPort);

            try
            {
                Sock.Connect(ipep);
                if (Sock.Connected)
                {
                    OnConnected();
                }
            }
            catch (SocketException se)
            {
                Cloger.WR(se.ToString());
                return(false);
            }
            return(true);
        }
 void CheckIDvalid(string sID)
 {
     if (sCheckedID == sID)
     {
         Cloger.WR("사용가능");
         return;
     }
     else
     {
         LoginNetManager.I.REQL_IDisValid(sID);
     }
 }
 public void res_IdIsValid(NETCODE.jPacket packet)
 {
     CommonData.RES_IdIsValid idv = jPacket.MakeObject <CommonData.RES_IdIsValid>(packet.JsonFormatData);
     if (idv.iResult == 0)
     {
         Cloger.WR("사용가능");
         iCheckIDvalid = idv.iResult;
     }
     else if (idv.iResult == 1)
     {
         Cloger.WR("사용불가");
         iCheckIDvalid = idv.iResult;
     }
 }
        private bool CheckExtraReceive()
        {
            try
            {
                Sock.BeginReceive(btTmpRecv, iTmpRecvCount, RECVDEFAULTSIZE - iTmpRecvCount, (SocketFlags)0, AsyncCallback_Receive, this);

                return(true);
            }
            catch (Exception ex)
            {
                Cloger.WR(ex.ToString());
                return(false);
            }
        }
        private void SendCallback(IAsyncResult ar)
        {
            lock (this)
            {
                int sendsize = Sock.EndSend(ar);

                if (sendsize < iTmpSendCount - iTmpSendCursor)//보낸크기 < (전체크기 - 보내기 완료한 크기) == 덜보냇다?
                {
                    iTmpSendCursor += sendsize;
                    Sock.BeginSend(btTmpSend, iTmpSendCursor, iTmpSendCount, (SocketFlags)0, AsyncCallback_Send, this);
                    return;
                }

                if (btSendQueue.Count == 0)//보낼게 없을 때 초기화@
                {
                    iTmpSendCount  = 0;
                    iTmpSendCursor = 0;
                    btTmpSend      = null;
                    bSending       = false;
                    return;
                }

                byte[] data = btSendQueue.Dequeue();
                if (data == null)//새로 보낼 때 초기화@
                {
                    iTmpSendCount  = 0;
                    iTmpSendCursor = 0;
                    btTmpSend      = null;
                    bSending       = false;
                    return;
                }

                iTmpSendCount  = data.Length; //이번 패킷의 전체 길이@
                iTmpSendCursor = 0;           //패킷 탐색 커서@
                btTmpSend      = data;        //보낼 패킷@

                try
                {
                    Sock.BeginSend(btTmpSend, iTmpSendCursor, iTmpSendCount, (SocketFlags)0, AsyncCallback_Send, this);//일딴 보낸다@
                }
                catch (Exception ex)
                {
                    Cloger.WR(ex.ToString());
                    bSending = false;
                }
            }
        }
 public void res_Registration(NETCODE.jPacket packet)
 {
     CommonData.RES_Regstration idr = jPacket.MakeObject <CommonData.RES_Regstration>(packet.JsonFormatData);
     if (idr.iResult == 0)
     {
         Cloger.WR("아이디.생성.성공적");
         bLoginMode = false;
     }
     else if (idr.iResult == 1)
     {
         Cloger.WR("UDID 중복");
     }
     else if (idr.iResult == 2)
     {
         Cloger.WR("아이디 중복");
         iCheckIDvalid = idr.iResult;
     }
 }
 public bool Connect()
 {
     try
     {
         if (nm.Connect() == false)
         {
             Cloger.WR("Connect ERROR");
             return(false);
         }
         nm.delegate_Receive += ReadLoginPacketProc;
         bCallOnce            = true;
         return(true);
     }
     catch (SocketException se)
     {
         Cloger.WR(se.ToString());
         return(false);
     }
 }
        public void OnReceive(byte[] btData)
        {
            jPacket packet = new jPacket();

            packet.Protocol       = BitConverter.ToUInt16(btData, 0);  //0~1
            packet.PacketOption   = BitConverter.ToUInt32(btData, 2);  //2~5
            packet.DataCRC        = BitConverter.ToUInt32(btData, 6);  //6~9
            packet.DataSize       = BitConverter.ToUInt16(btData, 10); //10~11
            packet.JsonFormatData = new byte[packet.DataSize];
            Buffer.BlockCopy(btData, 12, packet.JsonFormatData, 0, packet.DataSize);
            if (delegate_Receive != null)
            {
                delegate_Receive(packet);
            }
            else
            {
                Cloger.WR("delegate_Receive == null");
            }
        }
 public void res_Login(NETCODE.jPacket packet)
 {
     CommonData.RES_LoginInfo login = jPacket.MakeObject <CommonData.RES_LoginInfo>(packet.JsonFormatData);
     //CommonData.RES_LoginInfo login = new CommonData.RES_LoginInfo();
     if (login.iResult == 1)
     {
         Cloger.WR("없는 아이디/틀린아이디");
     }
     else if (login.iResult == 3)
     {
         Cloger.WR("서버 꽉참 재시도 대기");
     }
     else if (login.iResult == 4)
     {
         Cloger.WR("알 수 없는 에러");
     }
     else if (login.iResult == 0)
     {
         bLogined = true;
         Cloger.WR("로그인 성공");
     }
 }
    void req_registration()
    {
        if (iCheckIDvalid == 0)
        {
            Cloger.WR("중복확인 하세요");
            return;
        }
        else if (iCheckIDvalid == 2)
        {
            Cloger.WR("사용불가한 아이디");
            return;
        }


        string sID    = "";
        string sPwd   = "";
        string sMail  = "";
        string sExtra = "";
        string sUDID  = "";

        LoginNetManager.I.REQL_Registration(sID, sPwd, sMail, sExtra, sUDID);
    }
        private void sending()
        {
            lock (this)
            {
                if (true == bSending)
                {
                    return;
                }

                if (null == btTmpSend)
                {
                    if (btSendQueue.Count <= 0)
                    {
                        return;
                    }

                    byte[] data = btSendQueue.Dequeue();
                    if (null == data)
                    {
                        return;
                    }
                    btTmpSend      = data;
                    iTmpSendCount  = data.Length;
                    iTmpSendCursor = 0;
                }

                try
                {
                    bSending = true;
                    Sock.BeginSend(btTmpSend, iTmpSendCursor, iTmpSendCount, (SocketFlags)0, AsyncCallback_Send, this);
                }
                catch (Exception ex)
                {
                    Cloger.WR(ex.ToString());
                    Disconnect();
                    bSending = false;
                }
            }
        }
 private void MSG_ERROR_CONNECT()
 {
     Cloger.WR("ERROR : NOCONNECT");
 }