Skip to content
Permalink
Browse files

Initial commit

  • Loading branch information
sergejey committed Jan 12, 2020
1 parent 8b843df commit bbb528811b53a5b7ce7e6b339a584d92ebdb9fa2
Showing with 3,086 additions and 0 deletions.
  1. +241 −0 modules/yadevices/WSSC/Components/ClientConfig.php
  2. +218 −0 modules/yadevices/WSSC/Components/Connection.php
  3. +115 −0 modules/yadevices/WSSC/Components/ServerConfig.php
  4. +242 −0 modules/yadevices/WSSC/Components/WSClientTrait.php
  5. +434 −0 modules/yadevices/WSSC/Components/WscMain.php
  6. +150 −0 modules/yadevices/WSSC/Components/WssMain.php
  7. +64 −0 modules/yadevices/WSSC/Contracts/CommonsContract.php
  8. +23 −0 modules/yadevices/WSSC/Contracts/ConnectionContract.php
  9. +20 −0 modules/yadevices/WSSC/Contracts/MessageContract.php
  10. +30 −0 modules/yadevices/WSSC/Contracts/WebSocket.php
  11. +32 −0 modules/yadevices/WSSC/Contracts/WebSocketContract.php
  12. +45 −0 modules/yadevices/WSSC/Contracts/WebSocketServerContract.php
  13. +31 −0 modules/yadevices/WSSC/Contracts/WscCommonsContract.php
  14. +9 −0 modules/yadevices/WSSC/Exceptions/BadOpcodeException.php
  15. +8 −0 modules/yadevices/WSSC/Exceptions/BadUriException.php
  16. +8 −0 modules/yadevices/WSSC/Exceptions/ConnectionException.php
  17. +13 −0 modules/yadevices/WSSC/Exceptions/WebSocketException.php
  18. +28 −0 modules/yadevices/WSSC/WebSocketClient.php
  19. +328 −0 modules/yadevices/WSSC/WebSocketServer.php
  20. +618 −0 modules/yadevices/yadevices.class.php
  21. +9 −0 modules/yadevices/yadevices_edit.inc.php
  22. +6 −0 modules/yadevices/yadevices_search.inc.php
  23. +61 −0 modules/yadevices/yastations_edit.inc.php
  24. +30 −0 modules/yadevices/yastations_search.inc.php
  25. +80 −0 templates/yadevices/action_admin.html
  26. +1 −0 templates/yadevices/action_usual.html
  27. +9 −0 templates/yadevices/yadevices.html
  28. +23 −0 templates/yadevices/yadevices_edit.html
  29. +13 −0 templates/yadevices/yadevices_search_admin.html
  30. +108 −0 templates/yadevices/yastations_edit.html
  31. +89 −0 templates/yadevices/yastations_search_admin.html
@@ -0,0 +1,241 @@
<?php

namespace WSSC\Components;

use WSSC\Contracts\WscCommonsContract;

class ClientConfig
{
private $scheme;
private $host;
private $user;
private $password;
private $port;

private $timeout = WscCommonsContract::DEFAULT_TIMEOUT;
private $headers = [];
private $fragmentSize = WscCommonsContract::DEFAULT_FRAGMENT_SIZE;
private $context;

// proxy settings
private $hasProxy = false;
private $proxyIp;
private $proxyPort;
private $proxyAuth;

private $contextOptions = [];

/**
* @return int
*/
public function getTimeout(): int
{
return $this->timeout;
}

/**
* @param int $timeout
*/
public function setTimeout(int $timeout)
{
$this->timeout = $timeout;
}

/**
* @return array
*/
public function getHeaders(): array
{
return $this->headers;
}

/**
* @param array $headers
*/
public function setHeaders(array $headers)
{
$this->headers = $headers;
}

/**
* @return int
*/
public function getFragmentSize(): int
{
return $this->fragmentSize;
}

/**
* @param int $fragmentSize
*/
public function setFragmentSize(int $fragmentSize)
{
$this->fragmentSize = $fragmentSize;
}

/**
* @return mixed
*/
public function getContext()
{
return $this->context;
}

/**
* @param mixed $context
*/
public function setContext($context)
{
$this->context = $context;
}

/**
* @return mixed
*/
public function getScheme(): string
{
return $this->scheme;
}

/**
* @param void $scheme
*/
public function setScheme($scheme)
{
$this->scheme = $scheme;
}

/**
* @return string
*/
public function getHost(): string
{
return $this->host;
}

/**
* @param void $host
*/
public function setHost($host)
{
$this->host = $host;
}

/**
* @return string
*/
public function getUser(): string
{
return $this->user;
}

/**
* @param array $urlParts
*/
public function setUser(array $urlParts)
{
$this->user = isset($urlParts['user']) ? $urlParts['user'] : '';
}

/**
* @return string
*/
public function getPassword(): string
{
return $this->password;
}

/**
* @param array $urlParts
*/
public function setPassword(array $urlParts)
{
$this->password = isset($urlParts['pass']) ? $urlParts['pass'] : '';
}

/**
* @return string
*/
public function getPort(): string
{
return $this->port;
}

/**
* @param array $urlParts
*/
public function setPort(array $urlParts)
{
$this->port = isset($urlParts['port']) ? $urlParts['port'] : ($this->scheme === 'wss' ? '443' : '80');
}

/**
* @return array
*/
public function getContextOptions(): array
{
return $this->contextOptions;
}

/**
* @param array $contextOptions
*/
public function setContextOptions($contextOptions)
{
$this->contextOptions = $contextOptions;
}

/**
* @param string $ip
* @param string $port
*/
public function setProxy(string $ip, string $port): void
{
$this->hasProxy = true;
$this->proxyIp = $ip;
$this->proxyPort = $port;
}

/**
* Sets auth for proxy
*
* @param string $userName
* @param string $password
*/
public function setProxyAuth(string $userName, string $password): void
{
$this->proxyAuth = (empty($userName) === false && empty($password) === false) ? base64_encode($userName.':'.$password) : null;
}

/**
* @return bool
*/
public function hasProxy() : bool
{
return $this->hasProxy;
}

/**
* @return string|null
*/
public function getProxyIp() : string
{
return $this->proxyIp;
}

/**
* @return string|null
*/
public function getProxyPort() : string
{
return $this->proxyPort;
}

/**
* @return string|null
*/
public function getProxyAuth() : string
{
return $this->proxyAuth;
}
}

0 comments on commit bbb5288

Please sign in to comment.
You can’t perform that action at this time.