How to use the aquests.client.asynconnect.AsynConnect function in aquests

To help you get started, we’ve selected a few aquests examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hansroh / aquests / aquests / client / asynconnect.py View on Github external
def recv (self, buffer_size):		
		if self._handshaked or self._handshaking:
			return AsynSSLConnect.recv (self, buffer_size)				
		else:
			return AsynConnect.recv (self, buffer_size)
github hansroh / aquests / aquests / client / asynconnect.py View on Github external
def handle_connect_event (self):
		try:
			if not self._handshaked and not self.handshake ():
				return
		except:
			return self.handle_error (713)		
		AsynConnect.handle_connect_event (self)		
github hansroh / aquests / aquests / client / socketpool.py View on Github external
def create_asyncon (self, server, scheme):		
		if scheme in ("https", "wss"):
			__conn_class = asynconnect.AsynSSLConnect
			__dft_Port = 443
		elif scheme == "tunnel":
			__conn_class = asynconnect.AsynConnect
			__dft_Port = 443
		elif scheme == "proxy":
			__conn_class = asynconnect.AsynConnect			
			__dft_Port = 5000
		elif scheme == "proxys":
			__conn_class = asynconnect.AsynSSLProxyConnect
			__dft_Port = 5000				
		else:
			__conn_class = asynconnect.AsynConnect
			__dft_Port = 80

		if self.use_syn_connection:
			if scheme == "https":
				__conn_class = synconnect.SynSSLConnect
			elif scheme == "http":	
				__conn_class = synconnect.SynConnect
		try:
			addr, port = server.split (":", 1)
			port = int (port)
		except ValueError:
			addr, port = server, __dft_Port
		
		self.numobj += 1			
		asyncon = __conn_class ((addr, port), self.lock, self.logger)	
		self.backend and asyncon.set_backend ()
github hansroh / aquests / aquests / client / asynconnect.py View on Github external
def __init__ (self, address, lock = None, logger = None):
		AsynConnect.__init__ (self, address, lock, logger)
github hansroh / aquests / aquests / client / asynconnect.py View on Github external
def send (self, data):	
		if self._handshaked or self._handshaking:
			return AsynSSLConnect.send (self, data)
		else:
			return AsynConnect.send (self, data)
github hansroh / aquests / aquests / client / asynconnect.py View on Github external
self.set_event_time ()
		# IMP: call add_channel () AFTER push()	otherwise threading issue will be raised
		try:
			if not self.connected:				
				#print (self.handler.request.meta ['sid'], 'connecting...')
				self.connect ()
								
			elif not self.backend:
				#print (self.handler.request.meta ['sid'], 'add channel...')
				self.add_channel ()
				
		except:
			self.handle_error ()


class AsynSSLConnect (AsynConnect):	
	is_ssl = True

	def __init__ (self, address, lock = None, logger = None):
		AsynConnect.__init__ (self, address, lock, logger)
		self.ac_negotiate_http2 = True
	
	def negotiate_http2 (self, flag):
		self.ac_negotiate_http2 = flag
		
	def handshake (self):		
		if not self._handshaking:
			err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
			if err != 0:
				raise OSError(err, asyncore._strerror(err))
				
			ssl_context = create_urllib3_context(ssl_version=resolve_ssl_version(None), cert_reqs=resolve_cert_reqs(None))