API version 1

- ‐

get

指定先のサーバへ非同期GETリクエストを開始します。

メソッドは通信を開始した後に終了を待たずに直ちに終了します。

HTTPレイヤーの実行結果は、 SessionEnd イベントで返されるstatusの値で確認します。

呼出形式一覧

呼出形式

説明

void get(CRS::Common::Net::HttpRequest req)

HttpRequestを指定してGETリクエストを送信します。

void get(string id, string url)

セッションIDとURLを指定してGETリクエストを送信します。

戻り値一覧

戻り値

説明

void

なし

引数一覧

引数

説明

req

通信リクエストを示すHttpRequestオブジェクトを指定します。

createRequest メソッドで作成します。

id

セッションIDを指定します。

他の使用中のセッションIDと重複しないユニークな値を指定する必要があります。

すでに同じIDでリクエストが生成されている場合、例外が発生します。

url

要求するURLを指定します。

絶対パスまたは相対パス形式での指定が可能です。

例外

識別子

説明

SYS-50:1

通信エラー

SYS-50:2

URLが不正です

SYS-50:3

リクエストがエラー終了しました

CRS::Common::Core-1:1

不正な値です

CRS::Common::Net::HttpSession-1:2

指定のhttpRequestはコネクション先が異なります

CRS::Common::Net::HttpAsyncSession-1:2

指定のIDはすでに使用されています

関連項目

createRequestpost メソッド

SessionEnd イベント



使用例 CRSダウンロード

Form HTTPAsync1 {
   X = 0;
   Y = 0;
   width = 681;
   height = 441;
   Number id_num = 0;
   reference ref;

   httpAsyncSession asyncSession{
           Function OnSessionEnd( e ) {
                   ^.edtResult += "ID=" + e.id + " / ステータスコード=" + Str(e.status) +
                           " message=" + e.message + "\r\n";
                   ^.numSessionCount.Value = ^.asyncSession.sessions;
           }
   }

   Label Label3 {
           x = 15;
           y = 9;
           width = 338;
           Height = 20;
           Value = "非同期通信機能(ダウンロードボタンを複数回押します)";
   }

   TextBox txtURL {
           x = 14;
           y = 33;
           Width = 372;
           Height = 20;
           Value = "http://httpbin.org/image/png";
   }

   Button btnDownload {
           x = 15;
           y = 70;
           width = 102;
           Height = 30;
           Title = "ダウンロード(Get)";
           Function OnTouch( e ) {
                   try {
                           ^.id_num++;
                           print("通信中 ",^.asyncSession.isBusy() ) ;
                           ^.asyncSession.get("No." + Str(^.id_num), ^.txtURL.value);
                           ^.numSessionCount.Value = ^.asyncSession.sessions;
                   } catch(e) {
                           MessageBox("No." + Str(^.id_num) + " : Message=" + str(e.Message) + "\nCategory=" + str(e.Category) + "\nCode="+ str(e.Code)  + "\nSubCode=" + str(e.subCode));
                   }
                   Title = "ダウンロード(Get) : " + Str(^.id_num);
                   SetTimer(10);
           }
   }

   Label Label11 {
           x = 129;
           y = 78;
           width = 66;
           height = 24;
           Value = "sessions =";
   }

   NumberEdit numSessionCount {
           x = 196;
           y = 70;
           Width = 44;
           Height = 30;
           BgColor = Color.YELLOW;
   }
   Label Label13 {
           x = 15;
           y = 113;
           width = 404;
           Height = 18;
           Value = "ダウンロードの結果(ダウンロードが終了するとセッションが開放されます)";
   }
   EditBox edtResult {
           x = 16;
           y = 133;
           width = 385;
           height = 122;
   }
   Button Btn_abort {
           x = 254;
           y = 70;
           Width = 62;
           Height = 30;
           Title = "abort";

           Function OnTouch( e ) {
                   try{
                           ^.asyncSession.abort();
                   } catch( e ){
                           MessageBox("No." + Str(^.id_num) + " : Message=" + str(e.Message) + "\nCategory=" + str(e.Category) + "\nCode="+ str(e.Code)  + "\nSubCode=" + str(e.subCode));
                   }
           }
   }
   Button Btn_Reset {
           x = 322;
           y = 70;
           Width = 62;
           Height = 30;
           Title = "Reset";

           Function OnTouch( e ) {
                   ^.edtResult.Clear();
                   ^.id_num = 0;
                   ^.btnDownload.Title ="ダウンロード(Get)";
                   ^.btnDownload.RemoveTimer();
           }
   }

   Function OnTimer(e){
           numSessionCount.Value = asyncSession.sessions;
   }
}