133 @param name name of the local server to connect to (string) |
133 @param name name of the local server to connect to (string) |
134 """ |
134 """ |
135 self.name = name |
135 self.name = name |
136 self.connected = False |
136 self.connected = False |
137 |
137 |
138 def connect(self): |
138 def connect(self, timeout=10000): |
139 """ |
139 """ |
140 Public method to connect the single application client to its server. |
140 Public method to connect the single application client to its server. |
141 |
141 |
|
142 @param timeout connection timeout value in milliseconds |
|
143 @type int |
142 @return value indicating success or an error number. Value is one of: |
144 @return value indicating success or an error number. Value is one of: |
143 <table> |
145 <table> |
144 <tr><td>0</td><td>No application is running</td></tr> |
146 <tr><td>0</td><td>No application is running</td></tr> |
145 <tr><td>1</td><td>Application is already running</td></tr> |
147 <tr><td>1</td><td>Application is already running</td></tr> |
146 </table> |
148 </table> |
147 """ |
149 """ |
148 self.sock = QLocalSocket() |
150 self.sock = QLocalSocket() |
149 self.sock.connectToServer(self.name) |
151 self.sock.connectToServer(self.name) |
150 if self.sock.waitForConnected(10000): |
152 if self.sock.waitForConnected(timeout): |
151 self.connected = True |
153 self.connected = True |
152 return 1 |
154 return 1 |
153 else: |
155 else: |
154 err = self.sock.error() |
156 err = self.sock.error() |
155 if err == QLocalSocket.ServerNotFoundError: |
157 if err == QLocalSocket.ServerNotFoundError: |