Rename new_client to new_websocket_client, in order to have a better

name in the SocketServer/HTTPServer request handler hierarchy. Prepare
for merge pull request #72. This work has been picked out of
7b3dd8a6f5 .
This commit is contained in:
Peter Åstrand (astrand) 2013-11-28 13:33:28 +01:00
parent 558402848e
commit 047ce47742
8 changed files with 12 additions and 12 deletions

View File

@ -98,7 +98,7 @@ Sec-WebSocket-Accept: %s\r
begin begin
t[:client] = do_handshake(io) t[:client] = do_handshake(io)
new_client(t[:client]) new_websocket_client(t[:client])
rescue EClose => e rescue EClose => e
msg "Client closed: #{e.message}" msg "Client closed: #{e.message}"
return return

View File

@ -39,7 +39,7 @@ Traffic Legend:
end end
# Echo back whatever is received # Echo back whatever is received
def new_client(client) def new_websocket_client(client)
msg "connecting to: %s:%s" % [@target_host, @target_port] msg "connecting to: %s:%s" % [@target_host, @target_port]
tsock = TCPSocket.open(@target_host, @target_port) tsock = TCPSocket.open(@target_host, @target_port)

View File

@ -20,7 +20,7 @@ class WebSocketEcho(WebSocketServer):
client. """ client. """
buffer_size = 8096 buffer_size = 8096
def new_client(self): def new_websocket_client(self):
""" """
Echo back whatever is received. Echo back whatever is received.
""" """

View File

@ -12,7 +12,7 @@ require 'websocket'
class WebSocketEcho < WebSocketServer class WebSocketEcho < WebSocketServer
# Echo back whatever is received # Echo back whatever is received
def new_client(client) def new_websocket_client(client)
cqueue = [] cqueue = []
c_pend = 0 c_pend = 0

View File

@ -29,7 +29,7 @@ class WebSocketLoad(WebSocketServer):
WebSocketServer.__init__(self, *args, **kwargs) WebSocketServer.__init__(self, *args, **kwargs)
def new_client(self): def new_websocket_client(self):
self.send_cnt = 0 self.send_cnt = 0
self.recv_cnt = 0 self.recv_cnt = 0

View File

@ -124,4 +124,4 @@ class WebSocketProxyTest(unittest.TestCase):
return ins, outs, excepts return ins, outs, excepts
self.stubs.Set(select, 'select', mock_select) self.stubs.Set(select, 'select', mock_select)
self.assertRaises(Exception, web_socket_proxy.new_client) self.assertRaises(Exception, web_socket_proxy.new_websocket_client)

View File

@ -68,7 +68,7 @@ if multiprocessing and sys.platform == 'win32':
class WebSocketServer(object): class WebSocketServer(object):
""" """
WebSockets server class. WebSockets server class.
Must be sub-classed with new_client method definition. Must be sub-classed with new_websocket_client method definition.
""" """
log_prefix = "websocket" log_prefix = "websocket"
@ -770,7 +770,7 @@ Sec-WebSocket-Accept: %s\r
self.rec.write("var VNC_frame_data = [\n") self.rec.write("var VNC_frame_data = [\n")
self.ws_connection = True self.ws_connection = True
self.new_client() self.new_websocket_client()
except self.CClose: except self.CClose:
# Close the client # Close the client
_, exc, _ = sys.exc_info() _, exc, _ = sys.exc_info()
@ -797,15 +797,15 @@ Sec-WebSocket-Accept: %s\r
# Original socket closed by caller # Original socket closed by caller
self.request.close() self.request.close()
def new_client(self): def new_websocket_client(self):
""" Do something with a WebSockets client connection. """ """ Do something with a WebSockets client connection. """
raise("WebSocketServer.new_client() must be overloaded") raise("WebSocketServer.new_websocket_client() must be overloaded")
def start_server(self): def start_server(self):
""" """
Daemonize if requested. Listen for for connections. Run Daemonize if requested. Listen for for connections. Run
do_handshake() method for each connection. If the connection do_handshake() method for each connection. If the connection
is a WebSockets client then call new_client() method (which must is a WebSockets client then call new_websocket_client() method (which must
be overridden) for each new client connection. be overridden) for each new client connection.
""" """
lsock = self.socket(self.listen_host, self.listen_port, False, lsock = self.socket(self.listen_host, self.listen_port, False,

View File

@ -157,7 +157,7 @@ Traffic Legend:
# will be run in a separate forked process for each connection. # will be run in a separate forked process for each connection.
# #
def new_client(self): def new_websocket_client(self):
""" """
Called after a new WebSocket connection has been established. Called after a new WebSocket connection has been established.
""" """