-
Notifications
You must be signed in to change notification settings - Fork 7
/
event_message.dart
56 lines (47 loc) · 1.72 KB
/
event_message.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
part of dart_cassandra_cql.protocol;
class EventMessage extends Message {
EventRegistrationType type;
EventType subType;
// Filled in for topology/status messages
InternetAddress address;
int port;
// Filled in for schema messages
String keyspace;
String changedTable;
// V3-only
String changedType;
EventMessage.parse(TypeDecoder decoder) : super(Opcode.EVENT) {
type = EventRegistrationType.valueOf(decoder.readString(SizeType.SHORT));
subType = EventType.valueOf(decoder.readString(SizeType.SHORT));
switch (type) {
case EventRegistrationType.TOPOLOGY_CHANGE:
case EventRegistrationType.STATUS_CHANGE:
address = decoder.readTypedValue(new TypeSpec(DataType.INET),
size: SizeType.BYTE);
port = decoder.readInt();
break;
case EventRegistrationType.SCHEMA_CHANGE:
switch (decoder.protocolVersion) {
case ProtocolVersion.V2:
keyspace = decoder.readString(SizeType.SHORT);
// According to the spec, this should be an empty string if only the keyspace changed
String tableName = decoder.readString(SizeType.SHORT);
changedTable =
tableName == null || tableName.isEmpty ? null : tableName;
break;
case ProtocolVersion.V3:
String target = decoder.readString(SizeType.SHORT);
keyspace = decoder.readString(SizeType.SHORT);
switch (target) {
case "TABLE":
changedTable = decoder.readString(SizeType.SHORT);
break;
case "TYPE":
changedType = decoder.readString(SizeType.SHORT);
break;
}
}
break;
}
}
}