Пример #1
0
 def join(self, server_uuid):
     request = RequestJoin(self, server_uuid)
     resp = self._send_request(request)
     while True:
         yield resp
         if resp.code == REQUEST_TYPE_OK or resp.code >= REQUEST_TYPE_ERROR:
             return
         resp = Response(self, self._read_response())
     self.close()  # close connection after JOIN
Пример #2
0
    def _join_v16(self, server_uuid):
        request = RequestJoin(self, server_uuid)
        self._socket.sendall(bytes(request))

        while True:
            resp = Response(self, self._read_response())
            yield resp
            if resp.code == REQUEST_TYPE_OK or resp.code >= REQUEST_TYPE_ERROR:
                return
        self.close()  # close connection after JOIN
Пример #3
0
    async def join(self, server_uuid):
        request = RequestJoin(self, server_uuid)
        resp = await self._send_request(request)
        while True:
            await resp
            if resp.code == REQUEST_TYPE_OK or resp.code >= REQUEST_TYPE_ERROR:
                return

            resp = await self._wait_response(request.sync)

        # close connection after JOIN
        await self.close()
Пример #4
0
    def _join_v17(self, server_uuid):
        class JoinState:
            Handshake, Initial, Final, Done = range(4)

        request = RequestJoin(self, server_uuid)
        self._socket.sendall(bytes(request))
        state = JoinState.Handshake
        while True:
            resp = Response(self, self._read_response())
            yield resp
            if resp.code >= REQUEST_TYPE_ERROR:
                return
            elif resp.code == REQUEST_TYPE_OK:
                state = state + 1
                if state == JoinState.Done:
                    return