Skip to content

Commit

Permalink
Set the request timeout to 60 seconds by default
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouaini528 committed Jul 22, 2019
1 parent 844935e commit 0e9fd40
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/OkexFuture.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class OkexFuture
protected $host;

protected $proxy=false;
protected $timeout=60;

function __construct(string $key='',string $secret='',string $passphrase='',string $host='https://www.okex.com'){
$this->key=$key;
Expand All @@ -37,6 +38,7 @@ private function init(){
'secret'=>$this->secret,
'passphrase'=>$this->passphrase,
'host'=>$this->host,
'timeout'=>$this->timeout,
];
}

Expand All @@ -57,6 +59,13 @@ function setProxy($proxy=true){
$this->proxy=$proxy;
}

/**
* Set the request timeout to 60 seconds by default
* */
function setTimeOut($timeout=60){
$this->timeout=$timeout;
}

/**
*
* */
Expand Down
9 changes: 9 additions & 0 deletions src/OkexSpot.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class OkexSpot
protected $host;

protected $proxy=false;
protected $timeout=60;

function __construct(string $key='',string $secret='',string $passphrase='',string $host='https://www.okex.com'){
$this->key=$key;
Expand All @@ -36,6 +37,7 @@ private function init(){
'secret'=>$this->secret,
'passphrase'=>$this->passphrase,
'host'=>$this->host,
'timeout'=>$this->timeout,
];
}

Expand All @@ -56,6 +58,13 @@ function setProxy($proxy=true){
$this->proxy=$proxy;
}

/**
* Set the request timeout to 60 seconds by default
* */
function setTimeOut($timeout=60){
$this->timeout=$timeout;
}

/**
*
* */
Expand Down
9 changes: 9 additions & 0 deletions src/OkexSwap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class OkexSwap
protected $host;

protected $proxy=false;
protected $timeout=60;

function __construct(string $key='',string $secret='',string $passphrase='',string $host='https://www.okex.com'){
$this->key=$key;
Expand All @@ -38,6 +39,7 @@ private function init(){
'secret'=>$this->secret,
'passphrase'=>$this->passphrase,
'host'=>$this->host,
'timeout'=>$this->timeout,
];
}

Expand All @@ -58,6 +60,13 @@ function setProxy($proxy=true){
$this->proxy=$proxy;
}

/**
* Set the request timeout to 60 seconds by default
* */
function setTimeOut($timeout=60){
$this->timeout=$timeout;
}

/**
*
* */
Expand Down
3 changes: 3 additions & 0 deletions tests/future/accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

$okex=new OkexFuture($key,$secret,$passphrase);

//Set the request timeout to 60 seconds by default
//$okex->setTimeOut(10);

//This endpoint supports getting the list of assets(only show pairs with balance larger than 0), the balances, amount available/on hold in spot accounts.
try {
$result=$okex->account()->getAll();
Expand Down
3 changes: 3 additions & 0 deletions tests/spot/accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

$okex=new OkexSpot($key,$secret,$passphrase);

//Set the request timeout to 60 seconds by default
//$okex->setTimeOut(10);

//This endpoint supports getting the list of assets(only show pairs with balance larger than 0), the balances, amount available/on hold in spot accounts.
try {
$result=$okex->account()->getAll();
Expand Down
5 changes: 4 additions & 1 deletion tests/swap/accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
include 'key_secret.php';

$okex=new OkexSwap($key,$secret,$passphrase);
$okex->setProxy();
//$okex->setProxy();

//Set the request timeout to 60 seconds by default
//$okex->setTimeOut(10);

//This endpoint supports getting the list of assets(only show pairs with balance larger than 0), the balances, amount available/on hold in spot accounts.
try {
Expand Down

0 comments on commit 0e9fd40

Please sign in to comment.