Commit b6ec0eca authored by Jim Fulton's avatar Jim Fulton

Added protocol negotiation and test fixes

parent 7e5b78fc
...@@ -32,6 +32,8 @@ class Protocol(asyncio.Protocol): ...@@ -32,6 +32,8 @@ class Protocol(asyncio.Protocol):
transport = protocol_version = None transport = protocol_version = None
protocols = b"Z309", b"Z310", b"Z3101"
def __init__(self, loop, def __init__(self, loop,
addr, client, storage_key, read_only, connect_poll=1): addr, client, storage_key, read_only, connect_poll=1):
"""Create a client interface """Create a client interface
...@@ -179,8 +181,12 @@ class Protocol(asyncio.Protocol): ...@@ -179,8 +181,12 @@ class Protocol(asyncio.Protocol):
# lastTid before processing (and possibly missing) subsequent # lastTid before processing (and possibly missing) subsequent
# invalidations. # invalidations.
self.protocol_version = protocol_version self.protocol_version = min(protocol_version, self.protocols[-1])
self._write(protocol_version) # XXX protocol negotiation if self.protocol_version not in self.protocols:
self.client.register_failed(
self, ZEO.Exceptions.ProtocolError(protocol_version))
return
self._write(self.protocol_version)
register = self.promise( register = self.promise(
'register', self.storage_key, 'register', self.storage_key,
...@@ -351,7 +357,7 @@ class Client: ...@@ -351,7 +357,7 @@ class Client:
def disconnected(self, protocol=None): def disconnected(self, protocol=None):
if protocol is None or protocol is self.protocol: if protocol is None or protocol is self.protocol:
if protocol is self.protocol: if protocol is self.protocol and protocol is not None:
self.client.notify_disconnected() self.client.notify_disconnected()
self.ready = False self.ready = False
self.connected = concurrent.futures.Future() self.connected = concurrent.futures.Future()
...@@ -544,14 +550,6 @@ class Client: ...@@ -544,14 +550,6 @@ class Client:
self.close() self.close()
future.set_result(None) future.set_result(None)
# Methods called by the server:
client_methods = (
'invalidateTransaction', 'serialnos', 'info',
'receiveBlobStart', 'receiveBlobChunk', 'receiveBlobStop',
)
client_delegated = client_methods[1:]
def invalidateTransaction(self, tid, oids): def invalidateTransaction(self, tid, oids):
if self.ready: if self.ready:
for oid in oids: for oid in oids:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment