Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* wrap WebSocketTimeoutException as a ConnectionClosedException
* add more socket info

git-svn-id: https://xpra.org/svn/Xpra/trunk@13560 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 5, 2016
1 parent fb92b79 commit 8dc1257
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,11 +1496,11 @@ def setsid():

def connect_to(display_desc, opts=None, debug_cb=None, ssh_fail_cb=ssh_connect_failed):
from xpra.net.bytestreams import TCP_NODELAY, SOCKET_TIMEOUT, VSOCK_TIMEOUT
from xpra.net import ConnectionClosedException
display_name = display_desc["display_name"]
dtype = display_desc["type"]
conn = None
if dtype == "ssh":
from xpra.net import ConnectionClosedException
sshpass_command = None
try:
cmd = display_desc["full_ssh"]
Expand Down Expand Up @@ -1687,10 +1687,16 @@ class WebSocketClientConnection(Connection):
def __init__(self, ws, target, socktype):
Connection.__init__(self, target, socktype)
self._socket = ws

def peek(self, n):
return None

def untilConcludes(self, *args):
try:
return Connection.untilConcludes(self, *args)
except websocket.WebSocketTimeoutException as e:
raise ConnectionClosedException(e)

def read(self, n):
return self._read(self._socket.recv)

Expand All @@ -1714,6 +1720,14 @@ def __repr__(self):
def get_info(self):
d = Connection.get_info(self)
d["protocol-type"] = "websocket"
ws = self._socket
if ws:
d.update({
"sub-protocol" : ws.getsubprotocol(),
"fileno" : ws.fileno(),
"status" : ws.getstatus(),
"connected" : ws.connected,
})
return d
return WebSocketClientConnection(ws, "websocket", host)

Expand Down

0 comments on commit 8dc1257

Please sign in to comment.