Пример #1
0
        public MyBaseTransaction createTransaction(JObject obj)
        {
            string            transaction_type   = obj["MyTransactioncode"].ToString();
            MyBaseTransaction defaulttransaction = new MyBaseTransaction();

            switch (transaction_type)
            {
            case "1":
                defaulttransaction.MyTransactioncode = Transaction_Code.cl_disconnect;
                break;

            case "2":
                MyTr_Client_Connect_Infor transaction = new MyTr_Client_Connect_Infor(obj["username"].ToString(), obj["password"].ToString());

                return(transaction);

            case "3":
                defaulttransaction.MyTransactioncode = Transaction_Code.sv_disconnect;
                break;

            case "4":
                defaulttransaction.MyTransactioncode = Transaction_Code.sv_client_connect;
                break;

            case "5":
                defaulttransaction.MyTransactioncode = Transaction_Code.sv_client_disconnect;
                break;

            case "6":
                defaulttransaction.MyTransactioncode = Transaction_Code.sv_incorrect_info;
                break;

            case "7":
                defaulttransaction.MyTransactioncode = Transaction_Code.sv_login_accept;
                break;

            case "8":
                defaulttransaction.MyTransactioncode = Transaction_Code.sv_question;
                return(defaulttransaction);

            case "9":
                defaulttransaction.MyTransactioncode = Transaction_Code.cl_answer_question;
                break;

            case "10":
                defaulttransaction.MyTransactioncode = Transaction_Code.sv_end_questions;
                break;
            }
            return(defaulttransaction);
        }
Пример #2
0
        private void btLogin_Click(object sender, EventArgs e)
        {
            if (_socketMange.startConnection(tbIpServer.Text))
            {
                // send message to server
                MyTr_Client_Connect_Infor info = new MyTr_Client_Connect_Infor(tbName.Text, tbPassword.Text);

                _mysendFactory.sendJsonObject(info);

                NetworkStream networkStream = clientSocket.GetStream();
                byte[] bytesFrom = new byte[10025];
                networkStream.Read(bytesFrom, 0, (int)clientSocket.ReceiveBufferSize);
                string dataFromClient = MyDecodeUnicode.DecodeFromUtf8(Encoding.Unicode.GetString(bytesFrom));

                processRequest(dataFromClient);
            }
            else
            {
                MessageBox.Show("Server not found!", "Alert");
            }
        }
Пример #3
0
        public MyBaseTransaction createTransaction(JObject obj)
        {
            string transaction_type = obj["MyTransactioncode"].ToString();
            MyBaseTransaction defaulttransaction = new MyBaseTransaction();

            switch (transaction_type)
            {
                case "1":
                    defaulttransaction.MyTransactioncode = Transaction_Code.cl_disconnect;
                    break;
                case "2":
                    MyTr_Client_Connect_Infor transaction = new MyTr_Client_Connect_Infor(obj["username"].ToString(), obj["password"].ToString());

                    return transaction;
                case "3":
                    defaulttransaction.MyTransactioncode = Transaction_Code.sv_disconnect;
                    break;
                case "4":
                    defaulttransaction.MyTransactioncode = Transaction_Code.sv_client_connect;
                    break;
                case "5":
                    defaulttransaction.MyTransactioncode = Transaction_Code.sv_client_disconnect;
                    break;
                case "6":
                    defaulttransaction.MyTransactioncode = Transaction_Code.sv_incorrect_info;
                    break;
                case "7":
                    defaulttransaction.MyTransactioncode = Transaction_Code.sv_login_accept;
                    break;
                case "8":
                    defaulttransaction.MyTransactioncode = Transaction_Code.sv_question;
                    return defaulttransaction;
                case "9":
                    defaulttransaction.MyTransactioncode = Transaction_Code.cl_answer_question;
                    break;
                case "10":
                    defaulttransaction.MyTransactioncode = Transaction_Code.sv_end_questions;
                    break;
            }
            return defaulttransaction;
        }