# automatically generated by the FlatBuffers compiler, do not modify

# namespace: eventstore

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# This table stores WAMP sessions and serves as an anchor for all usage related data.
class Session(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAsSession(cls, buf, offset):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = Session()
        x.Init(buf, n + offset)
        return x

    # Session
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # The WAMP session_id of the session.
    # Session
    def Session(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # Timestamp when the session was joined by the router. Epoch time in ns.
    # Session
    def JoinedAt(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # Timestamp when the session left the router. Epoch time in ns.
    # Session
    def LeftAt(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # The WAMP realm the session is/was joined on.
    # Session
    def Realm(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The WAMP authid the session was authenticated under.
    # Session
    def Authid(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # The WAMP authrole the session was authenticated under.
    # Session
    def Authrole(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

def SessionStart(builder): builder.StartObject(6)
def SessionAddSession(builder, session): builder.PrependUint64Slot(0, session, 0)
def SessionAddJoinedAt(builder, joinedAt): builder.PrependUint64Slot(1, joinedAt, 0)
def SessionAddLeftAt(builder, leftAt): builder.PrependUint64Slot(2, leftAt, 0)
def SessionAddRealm(builder, realm): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(realm), 0)
def SessionAddAuthid(builder, authid): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(authid), 0)
def SessionAddAuthrole(builder, authrole): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(authrole), 0)
def SessionEnd(builder): return builder.EndObject()
