protected function createConnection(int $shardID) {
        if(empty($this->connections[$shardID])) {
            $this->connections[$shardID] = new \CharlotteDunois\Yasmin\WebSocket\WSConnection($this, $shardID, $this->compression);
            
            $this->connections[$shardID]->on('close', function (int $code, string $reason) use ($shardID) {
                $this->client->emit('debug', 'Shard '.$shardID.' disconnected with code '.$code.' and reason "'.$reason.'"');
                
                $shard = $this->client->shards->get($shardID);
                if($shard !== null) {
                    $this->client->emit('disconnect', $shard, $code, $reason);
                }
            });
        }
    }
protected function createConnection(int $shardID) {
        if(empty($this->connections[$shardID])) {
            $this->connections[$shardID] = new \CharlotteDunois\Yasmin\WebSocket\WSConnection($this, $shardID, $this->compression);
            
            $this->connections[$shardID]->on('close', function (int $code, string $reason) use ($shardID) {
                $this->client->emit('debug', 'Shard '.$shardID.' disconnected with code '.$code.' and reason "'.$reason.'"');
                
                $shard = $this->client->shards->get($shardID);
                if($shard !== null) {
                    $this->client->emit('disconnect', $shard, $code, $reason);
                }
            });
        }
    }
protected function createConnection ( int $ shardID ) { if ( empty ( $ this -> connections [ $ shardID ] ) ) { $ this -> connections [ $ shardID ] = new \ CharlotteDunois \ Yasmin \ WebSocket \ WSConnection ( $ this , $ shardID , $ this -> compression ) ; $ this -> connections [ $ shardID ] -> on ( 'close' , function ( int $ code , string $ reason ) use ( $ shardID ) { $ this -> client -> emit ( 'debug' , 'Shard ' . $ shardID . ' disconnected with code ' . $ code . ' and reason "' . $ reason . '"' ) ; $ shard = $ this -> client -> shards -> get ( $ shardID ) ; if ( $ shard !== null ) { $ this -> client -> emit ( 'disconnect' , $ shard , $ code , $ reason ) ; } } ) ; } }
Creates a new ws connection for a specific shard, if necessary.
@param int  $shardID
@return void
Creates a new ws connection for a specific shard if necessary .