first commit
This commit is contained in:
35
assets/scripts/network/http/HttpManager.ts
Normal file
35
assets/scripts/network/http/HttpManager.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { _decorator } from 'cc';
|
||||
import { HttpInvoke,HttpInvokeType } from "./HttpInvoke";
|
||||
|
||||
export class HttpManager {
|
||||
private static _instance: HttpManager = null;
|
||||
public static getInstance(): HttpManager {
|
||||
if (this._instance == null) {
|
||||
this._instance = new HttpManager();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
|
||||
protected _url:string = "";
|
||||
public setWebUrl(url:string):void{
|
||||
if(this._url == "" || this._url != url){
|
||||
this._url = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public doGet(name:string,apiUrl:string,params:any,otherData:any = null):void{
|
||||
var invoke = new HttpInvoke();
|
||||
invoke.init(name,otherData);
|
||||
invoke.doSend(this._url + apiUrl,params,HttpInvokeType.GET);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public doPost(name:string,apiUrl:string,params:any,otherData:any = null):void{
|
||||
var invoke = new HttpInvoke();
|
||||
invoke.init(name,otherData);
|
||||
invoke.doSend(this._url + apiUrl,params,HttpInvokeType.POST);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user