| 15 | |
| 16 | class ScratchCloud(LogCloud): |
| 17 | def __init__(self, *, project_id, _session=None): |
| 18 | super().__init__() |
| 19 | |
| 20 | self.project_id = project_id |
| 21 | |
| 22 | # Configure this object's attributes specifically for being used with Scratch's cloud: |
| 23 | self.cloud_host = "wss://clouddata.scratch.mit.edu" |
| 24 | self.length_limit = 256 |
| 25 | self._session = _session |
| 26 | if self._session is not None: |
| 27 | self.username = self._session.username |
| 28 | self.cookie = "scratchsessionsid=" + self._session.id + ";" |
| 29 | self.origin = "https://scratch.mit.edu" |
| 30 | |
| 31 | def connect(self): |
| 32 | self._assert_auth() # Connecting to Scratch's cloud websocket requires a login to the Scratch website |