Beispiel #1
0
 private void Login_FormClosed(object sender, FormClosedEventArgs e)
 {
     MyBaseTransaction info = new MyBaseTransaction();
     info.MyTransactioncode = Transaction_Code.cl_disconnect;
     _mysendFactory.sendJsonObject(info);
     _socketMange.stopConnection();
 }
Beispiel #2
0
        /// <summary>
        /// send data to server
        /// </summary>
        /// <param name="obj"></param>
        public void quickSendJsonObject(Transaction_Code transactioncode)
        {
            MyBaseTransaction transaction = new MyBaseTransaction();
            transaction.MyTransactioncode = transactioncode;

            sendJsonObject(transaction);
        }
Beispiel #3
0
        /// <summary>
        /// send data to server
        /// </summary>
        /// <param name="obj"></param>
        public void quickSendJsonObject(Transaction_Code transactioncode)
        {
            MyBaseTransaction transaction = new MyBaseTransaction();

            transaction.MyTransactioncode = transactioncode;

            sendJsonObject(transaction);
        }
        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);
        }
 internal void sendToAll(MyBaseTransaction transaction)
 {
     for(int i = 0; i < _lClients.Count; i++)
     {
         _lClients[i].sendTransaction(transaction);
     }
 }
 internal void sendToAll(Transaction_Code code)
 {
     MyBaseTransaction transaction = new MyBaseTransaction();
     transaction.MyTransactioncode = code;
     for (int i = 0; i < _lClients.Count; i++)
     {
         _lClients[i].sendTransaction(transaction);
     }
 }
        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;
        }
Beispiel #8
0
        private void stop()
        {
            MyBaseTransaction transaction = new MyBaseTransaction();
            transaction.MyTransactioncode = Transaction_Code.cl_disconnect;

            isRunning = false;
            _listenFromServer.Interrupt();
            _mysendFactory.sendJsonObject(transaction);
            mysocketManage.stopConnection();
        }
Beispiel #9
0
        private void Stop()
        {
            // Send a message to all client that server has been stopped
            MyBaseTransaction tr_disconect = new MyBaseTransaction();
            tr_disconect.MyTransactioncode = Transaction_Code.sv_disconnect;
            _myClientManage.sendToAll(tr_disconect);

            serverSocket.Stop();
            _myListenAccept.stop();
            _threadmanage.StopManage();
        }