Example #1
0
 private void btn_Login_Click(object sender, EventArgs e)
 {
     btn_Login.Enabled = false;
     Tefreeca_client_interface.Add_Command(Command_Client.Make_Login, new i_Make_Login(tbx_ID.Text, tbx_PW.Text)); //로그인 시도.
     UI.set_listBox_delegate(listBox_state_log, new string[] { client_message.로그인_시도중.ToString().Replace("_", " ") }, Option_listBox.add);
     Console.WriteLine("Login..");
 }
Example #2
0
        private void btn_connect_Click(object sender, EventArgs e)
        {
            if (mode == btn_mode.connect)
            {
                //주소길이 검사,
                if (tbx_BJID.Text.Trim().Length < 3)
                {
                    UI.set_listBox_delegate(listBox_state_log, new string[] { "BJ ID가 너무 짧습니다." }, Option_listBox.add);
                    return;
                }
                i_Make_Connect make_connect = new i_Make_Connect("http://play.afreecatv.com/" + tbx_BJID.Text.Trim(), Set_MaxConnect);

                Tefreeca_client_interface.Add_Command(Command_Client.Make_Connect, make_connect); //연결을 만든다.
                tbx_BJID.Enabled = false;
            }
            else if (mode == btn_mode.disconnect)
            {
                UI.set_button_delegate(btn_connect, false, Option_button.enable); //버튼 비활성화.
                Tefreeca_client_interface.Add_Command(Command_Client.Close_Order, null);
            }
        }
Example #3
0
 private void StartServer(String hostName, UInt16 hostPort)
 {
     tai = new Tefreeca_client_interface();
     while (true)
     {
         Console.WriteLine("try connecting...");
         UI.set_listBox_delegate(listBox_state_log, new string[] { "서버 연결중.." }, Option_listBox.add);
         tai.ConnectToServer(hostName, hostPort);
         if (!tai.is_connected())
         {
             Console.WriteLine("Failure, Re Connecting..");
             UI.set_listBox_delegate(listBox_state_log, new string[] { "서버 연결 실패." }, Option_listBox.add);
             continue;
         }
         else
         {
             Console.WriteLine("Connected!");
             UI.set_listBox_delegate(listBox_state_log, new string[] { "서버 연결 성공." }, Option_listBox.add);
             break;
         }
     }
 }
Example #4
0
        private static void Commander(command_data_client CMD)
        {
            Console.WriteLine("Command] {0} : ", ((Command_Client)CMD.Command_code).ToString());
            switch (CMD.Command_code)
            {
            case (int)Command_Client.Set_UnitNo:
            {
                Unit_No = Convert.ToInt32(CMD.data);
                Make_Client_Event(Unit_Event_Type.Change_connect, new List <object> {
                        true
                    });
            }
            break;

            case (int)Command_Client.Make_Login:
            {
                i_Make_Login login_info = (i_Make_Login)CMD.data;

                Tefreeca_client_interface.Add_Response(
                    Command_Server.Login,
                    new i_Login(
                        Unit_No,
                        login_info.ID,
                        MD5HashFunc(login_info.PW),
                        Type_User.Starter               //기본값은 스타터이나 로그인하면서 실제 회원등급을 전달받는다.
                        )
                    );
            }
            break;

            case (int)Command_Client.Login_success:
            {
                i_Login_success ils = JsonConvert.DeserializeObject <i_Login_success>(CMD.data.ToString());

                User_No    = ils.User_No;
                Unit_State = State_Unit.Logged;         //로그드를 사용하지 않고 일반 유닛처럼 운영.
                Session    = ils.Session;
                Type_user  = ils.Type_user;

                Add_Response(Command_Server.User_Info, null);

                Make_Client_Event(Unit_Event_Type.Login_success, new List <object> {
                    });
            }
            break;

            case (int)Command_Client.Login_Failure:
            {
                i_Login_Failure_type Failure_info = JsonConvert.DeserializeObject <i_Login_Failure_type>(CMD.data.ToString());

                Make_Client_Event(Unit_Event_Type.Login_Failure, new List <object> {
                        Failure_info
                    });
            }
            break;

            case (int)Command_Client.User_Info:
            {
                User_info = JsonConvert.DeserializeObject <i_User_info>(CMD.data.ToString());

                Make_Client_Event(Unit_Event_Type.User_info, new List <object> {
                        User_info
                    });
                //로그인 정보 가져오는 코드.
                ///그래서 받으면 폼에다 업데이트 할 수 있게 이벤트로 넘겨줌1
            }
            break;

            case (int)Command_Client.Order_No:
            {
                this_order_No = JsonConvert.DeserializeObject <int>(CMD.data.ToString());

                Make_Client_Event(Unit_Event_Type.Order_no, this_order_No);                                                              //이벤트 발생시키고

                i_Order io = new i_Order(this_order_No, User_No, this_order.Max_Connect, this_order.URL, Type_Order.Enter_Afreeca_Room); //실제 명령을 만든 후,

                Add_Response(Command_Server.Order_Connect, io);                                                                          //서버로 보낸다.
            }
            break;

            case (int)Command_Client.Error_Order:
            {
                client_message error_info = JsonConvert.DeserializeObject <client_message>(CMD.data.ToString());

                Make_Client_Event(Unit_Event_Type.Error_Order, new List <object> {
                        error_info
                    });
                //로그인 정보 가져오는 코드.
                ///그래서 받으면 폼에다 업데이트 할 수 있게 이벤트로 넘겨줌1
            }
            break;

            case (int)Command_Client.Make_Connect:
            {
                i_Make_Connect connect_info = (i_Make_Connect)CMD.data;
                this_order = connect_info;
                Add_Response(Command_Server.Order_Request_No, null);         //오더 리퀘스트 실행. 그러면 번호를 서버에서 생성하여 Order_No 응답이 온다.
            }
            break;

            case (int)Command_Client.Order_Info:
            {
                i_Order_Info order_info = JsonConvert.DeserializeObject <i_Order_Info>(CMD.data.ToString());

                Make_Client_Event(Unit_Event_Type.Order_Info, new List <object> {
                        order_info
                    });
            }
            break;

            case (int)Command_Client.Active_Order:
            {
                int order_no = JsonConvert.DeserializeObject <int>(CMD.data.ToString());
                if (this_order_No == order_no)
                {
                    Make_Client_Event(Unit_Event_Type.Active_Order, order_no);
                }
            }
            break;

            case (int)Command_Client.Close_Order:     //폼 컨르롤로부터 연결 해지 명령을 받을때 사용, 이 명령을 받으면 현재 활성화된 오더를 닫는 명령을 서버로 보낸다.
            {
                Add_Response(Command_Server.Order_Disconnect, this_order_No);
            }
            break;

            case (int)Command_Client.Make_Order_Set_MaxConnect:
            {
                int set_maxConnect = JsonConvert.DeserializeObject <int>(CMD.data.ToString());

                i_Set_MaxConnect iset = new i_Set_MaxConnect(User_No, this_order_No, set_maxConnect);

                Add_Response(Command_Server.Order_Set_MaxConnect, iset);
            }
            break;

            case (int)Command_Client.R_Order_Set_MaxConnect:
            {
                i_R_Order_Set_MaxConnect ir = JsonConvert.DeserializeObject <i_R_Order_Set_MaxConnect>(CMD.data.ToString());
                Make_Client_Event(Unit_Event_Type.Order_Set_MaxConnect, new List <object> {
                        ir
                    });
            }
            break;

            case (int)Command_Client.HeartBeat:
            {
            }
            break;

            default:
            {
                Command_Client S = (Command_Client)CMD.Command_code;
                Console.WriteLine("Unknown Command : {0}", S.ToString());
            }
            break;
            }
        }
Example #5
0
 private void btn_set_Maxconnect_Click(object sender, EventArgs e)
 {
     Tefreeca_client_interface.Add_Command(Command_Client.Make_Order_Set_MaxConnect, int.Parse(numericUpDown_MaxConnect.Value.ToString()));
     UI.set_listBox_delegate(listBox_state_log, new string[] { "최대 연결 수 변경 요청" }, Option_listBox.add);
 }
Example #6
0
 private void TefreecaClient_FormClosing(object sender, FormClosingEventArgs e)
 {
     Tefreeca_client_interface.Server_Disconnect();
     Application.Exit();
 }