예제 #1
0
def _init_link_session_disconnected_tag():
    props = []
    props.append(MetaProperty('link_name', 9))
    props.append(MetaProperty('handle', 5))
    props.append(MetaProperty('context', 15))
    return Event.Tag(Event.tag, 'LinkSessionDisconnected', props,
                     LinkEventType.LINK_SESSION_DISCONNECTED)
예제 #2
0
파일: test.py 프로젝트: jaykang920/x2py
def _init_my_cell3_tag():
    props = []
    props.append(MetaProperty('cell', 11, runtime_type=MyCell1))
    props.append(MetaProperty('list', 13, details=[MetaProperty(None, 5)]))
    props.append(
        MetaProperty('map',
                     14,
                     details=[MetaProperty(None, 5),
                              MetaProperty(None, 9)]))
    return Cell.Tag(None, 'MyCell3', props)
예제 #3
0
def _init_hello_req_tag():
    props = []
    props.append(MetaProperty('name', 9))
    return Event.Tag(Event.tag, 'HelloReq', props, 1)
예제 #4
0
def _init_hello_resp_tag():
    props = []
    props.append(MetaProperty('message', 9))
    return Event.Tag(Event.tag, 'HelloResp', props, 2)
예제 #5
0
파일: event.py 프로젝트: jaykang920/x2py
class Event(Cell):
    """Common base class for all events."""
    class Tag(Cell.Tag):
        def __init__(self, base, type_name, props, type_id):
            Cell.Tag.__init__(self, base, type_name, props)
            self.type_id = type_id

    tag = Tag(None, 'Event', [
        MetaProperty('_Handle', MetaProperty.INT32),
        MetaProperty('_WaitHandle', MetaProperty.INT32)
    ], 0)

    def __init__(self, length=0):
        super(Event, self).__init__(len(Event.tag.props) + length)
        self._transform = True
        base = Event.tag.offset
        self.values[base + 0] = 0
        self.values[base + 1] = 0

    @property
    def _handle(self):
        return self.values[Event.tag.offset + 0]

    @_handle.setter
    def _handle(self, value):
        self._set_property(Event.tag.offset + 0, value,
                           Event.tag.props[0].type_index)

    @property
    def _wait_handle(self):
        return self.values[Event.tag.offset + 1]

    @_wait_handle.setter
    def _wait_handle(self, value):
        self._set_property(Event.tag.offset + 1, value,
                           Event.tag.props[1].type_index)

    def desc(self):
        prop_descs = []
        tag = self.type_tag()
        self._desc(tag, prop_descs)
        result = ', '.join(prop_descs)
        result = "{} {} {{ {} }}".format(tag.type_id, tag.type_name, result)
        return result

    def in_response_of(self, request):
        self._handle = request._handle
        return self

    def post(self):
        """Posts up this event to the hub."""
        from x2py.hub import Hub
        Hub.post(self)

    def type_id(self):
        return Event.tag.type_id

    def type_tag(self):
        return Event.tag

    def hash_code_for(self, fingerprint, type_id):
        value = self.hash_code(fingerprint)
        value = hash_update(value, -1)  # delimiter for type id
        value = hash_update(value, type_id)
        return value

    def __hash__(self):
        return self.hash_code_for(self.fingerprint, self.type_id())
예제 #6
0
def _init_handshake_ack_tag():
    props = []
    props.append(MetaProperty('result', 1))
    return Event.Tag(Event.tag, 'HandshakeAck', props,
                     LinkEventType.HANDSHAKE_ACK)
예제 #7
0
def _init_handshake_resp_tag():
    props = []
    props.append(MetaProperty('data', 11))
    return Event.Tag(Event.tag, 'HandshakeResp', props,
                     LinkEventType.HANDSHAKE_RESP)
예제 #8
0
파일: test.py 프로젝트: jaykang920/x2py
def _init_my_cell2_tag():
    props = []
    props.append(MetaProperty('bar', 9))
    return Cell.Tag(MyCell1.tag, 'MyCell2', props)
예제 #9
0
파일: test.py 프로젝트: jaykang920/x2py
def _init_my_event2_tag():
    props = []
    props.append(MetaProperty('bar', 9))
    return Event.Tag(MyEvent1.tag, 'MyEvent2', props, 2)
예제 #10
0
파일: test.py 프로젝트: jaykang920/x2py
def _init_my_event1_tag():
    props = []
    props.append(MetaProperty('foo', 9))
    return Event.Tag(Event.tag, 'MyEvent1', props, 1)
예제 #11
0
파일: test.py 프로젝트: jaykang920/x2py
def _init_my_cell1_tag():
    props = []
    props.append(MetaProperty('foo', 5))
    return Cell.Tag(None, 'MyCell1', props)
예제 #12
0
def _init_timeout_event_tag():
    props = []
    props.append(MetaProperty('key', 15))
    props.append(MetaProperty('int_param', 5))
    return Event.Tag(Event.tag, 'TimeoutEvent', props,
                     BuiltinEventType.TIMEOUT_EVENT)
예제 #13
0
def _init_periodic_event_tag():
    props = []
    props.append(MetaProperty('key', 15))
    props.append(MetaProperty('int_param', 5))
    return Event.Tag(Event.tag, 'PeriodicEvent', props,
                     BuiltinEventType.PERIODIC_EVENT)