pygui: added wrapper class for sessions returned by grpc GetSession

This commit is contained in:
Blake Harnden 2020-07-26 11:45:40 -07:00
parent 82a212d1cf
commit 41a3c5fd7f
3 changed files with 32 additions and 11 deletions

View file

@ -545,6 +545,27 @@ class Node:
)
@dataclass
class Session:
id: int
state: SessionState
nodes: List[Node]
links: List[Link]
dir: str
@classmethod
def from_proto(cls, proto: core_pb2.Session) -> "Session":
nodes = [Node.from_proto(x) for x in proto.nodes]
links = [Link.from_proto(x) for x in proto.links]
return Session(
id=proto.id,
state=SessionState(proto.state),
nodes=nodes,
links=links,
dir=proto.dir,
)
@dataclass
class LinkEvent:
message_type: MessageType