示例#1
0
        /*
         * Sending Packet to Server
         */
        public static void Handling()
        {
            while (MainClass.IsRunning())
            {
                byte[] buffer = CDataHandler.Handling_SendPacket();
                if (buffer == null)
                {
                    continue;
                }

                NWM_log("Sending Packet");
                SocketAsyncEventArgs Asynce = new SocketAsyncEventArgs();
                Asynce.SetBuffer(buffer, 0, buffer.Length);
                Asynce.Completed += new EventHandler <SocketAsyncEventArgs>(Send);
                if (Client.Connected)
                {
                    try
                    {
                        Client.SendAsync(Asynce);
                    }
                    catch (SocketException se)
                    {
                        Console.WriteLine("Socket Exception : " + se.ErrorCode + "Message : " + se.Message);
                    }
                }
                else
                {
                    CDataFactory DataFactory = CDataFactory.GetDataFactory();
                    DataFactory.SetPopupBuffer("서버와의 연결이 끊겼습니다");
                    MainClass.SetRunning(false);
                }
            }
        }
示例#2
0
 /*
  * send ID and Pass to DataHandler
  */
 public bool RegistRequest(string ID, string Pass)
 {
     try
     {
         return(CDataHandler.Handling_RegisterRequest(ID, Pass));
     }
     catch (Exception e)
     {
         return(false);
     }
 }
示例#3
0
 private void Run()
 {
     while (MainClass.IsRunning())
     {
         Popup_Message = CDataHandler.Handling_PopupMessage();
         if (Popup_Message != null)
         {
             break;
         }
     }
     Message.Text = Popup_Message;
     this.Show();
 }
示例#4
0
        /*
         * Do nothing
         */
        private static void Handling()
        {
            string Popup_Message;

            while (MainClass.IsRunning())
            {
                Popup_Message = CDataHandler.Handling_PopupMessage();
                if (Popup_Message == null)
                {
                    continue;
                }
                PM_log("working");
                PM_log(Popup_Message);
            }
        }
示例#5
0
    /*
     * BackgroundWorker Dowork
     */
    private void Popup_Dowork(object sender, DoWorkEventArgs e)
    {
        BackgroundWorker worker        = (BackgroundWorker)sender;
        string           Popup_Message = "";

        Console.WriteLine("Background Worker Do Process");
        while (true)
        {
            Popup_Message = CDataHandler.Handling_PopupMessage();
            if (Popup_Message == null)
            {
                continue;
            }
            break;
        }
        e.Result = Popup_Message;
    }
示例#6
0
        /*
         * Do nothing
         */
        public static string GetMessageFromServer()
        {
            string Message;

            while (true)
            {
                Message = CDataHandler.Handling_PopupMessage();
                if (Message == null)
                {
                    continue;
                }

                PM_log(Message);
                break;
            }
            return(Message);
        }
示例#7
0
        /*
         * Recieve Packet Async
         */
        private static void Recieve(object sender, SocketAsyncEventArgs e)
        {
            Socket client = (Socket)sender;

            if (Client.Connected && e.BytesTransferred > 0)
            {
                NWM_log("Receving Packet");
                byte[] buffer = e.Buffer;
                CDataHandler.Handling_RecvPacket(buffer);

                if (!client.ReceiveAsync(e))
                {
                    client.ReceiveAsync(e);
                }
            }
            else
            {
                client.Close();
                Console.WriteLine("Connection Losted");
                CDataFactory DataFactory = CDataFactory.GetDataFactory();
                DataFactory.SetPopupBuffer("서버와의 연결이 끊겼습니다");
                MainClass.SetRunning(false);
            }
        }