<commit_before># Clientside

## Setting up a connection
You want to send a JSON-RPC request, right?  
So, the first question we need to answer to is: Where are we going to send it to?

For demonstration purposes, let's assume we want to send a JSON-RPC request to `http://example.com/api/json-rpc` (although, of course, this resource doesn't provide much useful data...).

```php
<?php
$target = 'http://example.com/api/json-rpc';
?>
```

Now, we simply connect to this URL, using the following method:

```php
<?php
$connection = Tivoka\Client::connect($target);
?>
```

### TCP Connections
In order to connect to a pure TCP JSON-RPC server, use this:
```php
<?php
$connection = Tivoka\Client:connect(Array('server'=>$server, 'port'=>$port));
?>
```

### Connection modifiers
To set a specific spec version, call `->useSpec()`:
```php
<?php
$connection->useSpec('1.0');
?>
```
The default spec version is `'2.0'`.

Set a connection timeout, using `->setTimeout($timeInSecs)`. The default timeout is `5` seconds.<commit_msg>Adding documentation about WebSocket client.<commit_after># Clientside

## Setting up a connection
You want to send a JSON-RPC request, right?  
So, the first question we need to answer to is: Where are we going to send it to?

For demonstration purposes, let's assume we want to send a JSON-RPC request to `http://example.com/api/json-rpc` (although, of course, this resource doesn't provide much useful data...).

```php
<?php
$target = 'http://example.com/api/json-rpc';
?>
```

Now, we simply connect to this URL, using the following method:

```php
<?php
$connection = Tivoka\Client::connect($target);
?>
```

### WebSocket Connections
If the URL happens to be a WebSocket URL (starting with ws or wss), a (persistant) WebSocket connection is made:
```php
$target = 'ws://example.com/api/json-rpc';
```
Note: This requires the dependencies from composer.json to be installed.

### TCP Connections
In order to connect to a pure TCP JSON-RPC server, use this:
```php
<?php
$connection = Tivoka\Client:connect(Array('server'=>$server, 'port'=>$port));
?>
```

### Connection modifiers
To set a specific spec version, call `->useSpec()`:
```php
<?php
$connection->useSpec('1.0');
?>
```
The default spec version is `'2.0'`.

Set a connection timeout, using `->setTimeout($timeInSecs)`. The default timeout is `5` seconds.
{'fraction_non_alphanumeric': 0.1504688832054561, 'fraction_numerical': 0.004262574595055414, 'mean_word_length': 4.766584766584766, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3797820', 'n_tokens_mistral': 732, 'n_tokens_neox': 704, 'n_words': 288}