Beispiel #1
0
    def disconect_user(self, username):
        socket = self._active_connections.get_user_socket(username)

        if socket:
            socket.close()
            socket.shutdown()
            self._active_connections.remove_user(username)
    def run(self) -> None:
        from robocorp_ls_core.debug_adapter_core.debug_adapter_threads import (
            STOP_WRITER_THREAD,
        )

        socket, _addr = self._server_socket.accept()
        self._server_socket.close()

        from robocorp_ls_core.debug_adapter_core.debug_adapter_threads import (
            writer_thread,
        )
        from robocorp_ls_core.debug_adapter_core.debug_adapter_threads import (
            reader_thread,
        )
        import queue
        from robotframework_debug_adapter_tests.fixtures import _DebuggerAPI

        read_from = socket.makefile("rb")
        write_to = socket.makefile("wb")

        write_queue: queue.Queue = queue.Queue()
        read_queue: queue.Queue = queue.Queue()

        writer = threading.Thread(
            target=writer_thread,
            args=(write_to, write_queue),
            name="Client debugger API writer",
        )
        writer.daemon = True
        reader = threading.Thread(
            target=reader_thread,
            args=(read_from, read_queue.put, read_queue),
            name="Client debugger API reader",
        )
        reader.daemon = True

        reader.start()
        writer.start()

        self.debugger_api = _DebuggerAPI(
            reader=reader,
            writer=writer,
            write_queue=write_queue,
            read_queue=read_queue,
            dap_resources_dir=None,
        )
        self.started.set()

        try:
            assert self.finish.wait(5)
            write_queue.put(STOP_WRITER_THREAD)
            socket.shutdown(SHUT_WR)
            socket.close()
        except:
            log.exception()
        finally:
            self.sockets_closed.set()
Beispiel #3
0
 def shutdown(self, how):
     self._checkClosed()
     self._sslobj = None
     socket.shutdown(self, how)
Beispiel #4
0
 def shutdown(self, how):
     self._sslobj = None
     socket.shutdown(self, how)
Beispiel #5
0
def game_disconnect(socket: socket):
    socket.sendall(bytes([255]))
    socket.shutdown(SHUT_RDWR)
    socket.close()

    return None  # Returns None so self.socket can be easily set to None in one line
Beispiel #6
0
 def shutdown(self, how):
     self._sslobj = None
     socket.shutdown(self, how)
Beispiel #7
0
 def shutdown(self, how):
     if self.native_object != _ffi.NULL:
         _lib.wolfSSL_shutdown(self.native_object)
         self._release_native_object()
     socket.shutdown(self, how)
 def shutdown(self, how):
     if self.native_object != _ffi.NULL:
         _lib.wolfSSL_shutdown(self.native_object)
         self._release_native_object()
     socket.shutdown(self, how)
Beispiel #9
0
 def disconect(self, address: Address):
     if socket := self._active_connections.get_socket(address):
         socket.close()
         socket.shutdown()
         self._active_connections.remove_address(address)
Beispiel #10
0
        socket.sendall(filename)
        response = socket.recv(recv_buffer_length)
        print 'Response :', response
        # If the name is not free user have 5 attempts to choose another one
        while response != '0' and attempts != 0:
            new_filename = raw_input('Filename already exists. '
                                     'Choose another name: ')
            socket.send(new_filename)
            response = socket.recv(recv_buffer_length)
            print 'Response :', response
            if response == '1' and attempts != 0:
                attempts -= 1

            elif attempts == 0:
                print 'Out of attempts.'
                socket.shutdown(SHUT_WR)
                socket.close()
                break

        # If the name is free
        if response == '0':
            with open(CLIENT_HOME_PATH + new_filename, 'w+') as new_file:
                # Editing file...

                # Saving file...

                # Sending file to server
                data = new_file.read()
                socket.sendall(data)
            socket.shutdown(SHUT_WR)
            socket.close()
Beispiel #11
0
def socketclose(socket):
    '''Closing socket'''
    socket.shutdown(SHUT_RDWR)
    socket.close()