/*-------------------------------------------------------------------------
         * データ受信
         * データを分解してハンドラに渡す
         * ---------------------------------------------------------------------------*/
        private void received_handler(object sender, ReceivedDataEventArgs e)
        {
            string[] datas = e.received_string.Split(':');
            if (datas.Length <= 0)
            {
                return;                                         // データエラー
            }
            // バージョン情報
            if (datas[0] == VERSION_COMMAND)
            {
                if (datas.Length != 3)
                {
                    // エラー
                    m_state = client_state.error_version;
                    return;
                }
                if ((datas[1] != m_version.ToString()) ||
                    (datas[2] != m_protocol_name))
                {
                    // エラー
                    m_state = client_state.error_version;
                    return;
                }
                // 通信可能
                m_state = client_state.ready;
                return;
            }

            // ハンドラに渡す
            if (ReceivedCommand != null)
            {
                ReceivedCommand(this, datas);
            }
        }
Esempio n. 2
0
 public Client(int _ID, int _req_max_count)
 {
     ID = _ID;
     req_max_count = _req_max_count;
     req = new Request[req_max_count];
     req_done = 0;
     state = client_state.Undefined;
 }
Esempio n. 3
0
        private int req_done; //количество обработанных заявок

        #endregion Fields

        #region Constructors

        public Client()
        {
            ID = 0;
            req_count = 0;
            req_max_count = 0;
            req_done = 0;
            state = client_state.Undefined;
        }
Esempio n. 4
0
 public Client(int _ID, int _req_max_count)
 {
     ID            = _ID;
     req_max_count = _req_max_count;
     req           = new Request[req_max_count];
     req_done      = 0;
     state         = client_state.Undefined;
 }
Esempio n. 5
0
 private int req_done;              //количество обработанных заявок
 public Client()
 {
     ID            = 0;
     req_count     = 0;
     req_max_count = 0;
     req_done      = 0;
     state         = client_state.Undefined;
 }
        /*-------------------------------------------------------------------------
         *
         * ---------------------------------------------------------------------------*/
        private void init(string protocol_name, int version)
        {
            m_protocol_name = protocol_name;                                    // プロトコル名
            m_version       = version;                                          // プロトコルバージョン
            m_state         = client_state.init;                                // 初期化中

            // データ受信時のハンドラ
            base.ReceivedData += new ReceivedDataEventHandler(received_handler);
        }
Esempio n. 7
0
 public Client(Client _other)
 {
     ID = _other.ID;
     req_max_count = _other.req_max_count;
     req_count = _other.req_count;
     req_done = _other.req_done;
     for (int i = 0; i < req_count; i++)
         req[i] = _other.req[i];
     state = _other.state;
 }
Esempio n. 8
0
 public Client(Client _other)
 {
     ID            = _other.ID;
     req_max_count = _other.req_max_count;
     req_count     = _other.req_count;
     req_done      = _other.req_done;
     for (int i = 0; i < req_count; i++)
     {
         req[i] = _other.req[i];
     }
     state = _other.state;
 }
 /*-------------------------------------------------------------------------
  * サーバから切断された
  * サーバから切断した
  * ---------------------------------------------------------------------------*/
 protected override void OnDisconnected(EventArgs e)
 {
     base.OnDisconnected(e);
     m_state = client_state.disconected;                                 // 切断
 }
 /*-------------------------------------------------------------------------
  * バージョン情報を送る
  * ---------------------------------------------------------------------------*/
 private void send_version()
 {
     m_state = client_state.chekc_version;
     base.Send(CreatePacket(VERSION_COMMAND, new string[] { m_version.ToString(), m_protocol_name }));
 }