# eric6.Toolbox.SingleApplication

Module implementing the single application server and client.

### Global Attributes

None

### Classes

SingleApplicationClient | Class implementing the single application client base class.
SingleApplicationServer | Class implementing the single application server base class.

### Functions

None

## SingleApplicationClient

Class implementing the single application client base class.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

SingleApplicationClient | Constructor
connect | Public method to connect the single application client to its server.
disconnect | Public method to disconnect from the Single Appliocation server.
errstr | Public method to return a meaningful error string for the last error.
processArgs | Public method to process the command line args passed to the UI.
sendCommand | Public method to send the command to the application server.

### Static Methods

None

#### SingleApplicationClient (Constructor)

SingleApplicationClient(name)

Constructor

name
  name of the local server to connect to (string)

#### SingleApplicationClient.connect

connect(timeout=10000)

Public method to connect the single application client to its server.

timeout (int)
  connection timeout value in milliseconds

Returns:
  value indicating success or an error number. Value is one of:

  0 | No application is running
  1 | Application is already running

#### SingleApplicationClient.disconnect

disconnect()

Public method to disconnect from the Single Appliocation server.

#### SingleApplicationClient.errstr

errstr()

Public method to return a meaningful error string for the last error.

Returns:
  error string for the last error (string)

#### SingleApplicationClient.processArgs

processArgs(args)

Public method to process the command line args passed to the UI.

Note: This method must be overridden by subclasses.

args
  command line args (list of strings)

Raises RuntimeError:
  raised to indicate that this method must be implemented by a subclass

#### SingleApplicationClient.sendCommand

sendCommand(command, arguments)

Public method to send the command to the application server.

command (str)
  command to be sent to the server
arguments (list of str)
  list of command arguments

Up

## SingleApplicationServer

Class implementing the single application server base class.

### Derived from

QLocalServer

### Class Attributes

None

### Class Methods

None

### Methods

SingleApplicationServer | Constructor
__disconnected | Private method to handle the closure of the socket.
__newConnection | Private slot to handle a new connection.
__receiveJson | Private method to receive the data from the client.
handleCommand | Public slot to handle the command sent by the client.
shutdown | Public method used to shut down the server.

### Static Methods

None

#### SingleApplicationServer (Constructor)

SingleApplicationServer(name)

Constructor

name
  name this server is listening to (string)

#### SingleApplicationServer.__disconnected

__disconnected()

Private method to handle the closure of the socket.

#### SingleApplicationServer.__newConnection

__newConnection()

Private slot to handle a new connection.

#### SingleApplicationServer.__receiveJson

__receiveJson()

Private method to receive the data from the client.

#### SingleApplicationServer.handleCommand

handleCommand(command, arguments)

Public slot to handle the command sent by the client.

Note: This method must be overridden by subclasses.

command (str)
  command sent by the client
arguments (list of str)
  list of command arguments

Raises RuntimeError:
  raised to indicate that this method must be implemented by a subclass

#### SingleApplicationServer.shutdown

shutdown()

Public method used to shut down the server.

Up