code: async def from_client(cls, client, *, shard_id=None, session=None, sequence=None, resume=False):
          
          gateway = await client.http.get_gateway()
          ws = await websockets.connect(gateway, loop=client.loop, klass=cls, compression=None)
  
          # dynamically add attributes needed
          ws.token = client.http.token
          ws._connection = client._connection
          ws._dispatch = client.dispatch
          ws.gateway = gateway
          ws.shard_id = shard_id
          ws.shard_count = client._connection.shard_count
          ws.session_id = session
          ws.sequence = sequence
          ws._max_heartbeat_timeout = client._connection.heartbeat_timeout
  
          client._connection._update_references(ws)
  
          log.info('Created websocket connected to %s', gateway)
  
          # poll event for OP Hello
          await ws.poll_event()
  
          if not resume:
              await ws.identify()
              return ws
  
          await ws.resume()
          try:
              await ws.ensure_open()
          except websockets.exceptions.ConnectionClosed:
              # ws got closed so let's just do a regular IDENTIFY connect.
              log.info('RESUME failed (the websocket decided to close) for Shard ID %s. Retrying.', shard_id)
              return await cls.from_client(client, shard_id=shard_id)
          else:
              return ws
docs: Creates a main websocket for Discord from a :class:`Client`.
  
          This is for internal use only.