Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

message_fbs.py 4.5KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ###############################################################################
  2. #
  3. # The MIT License (MIT)
  4. #
  5. # Copyright (c) typedef int GmbH
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. # THE SOFTWARE.
  24. #
  25. ###############################################################################
  26. import flatbuffers
  27. from autobahn.wamp.gen.wamp.proto import Event as EventGen
  28. from autobahn.wamp.gen.wamp.proto import Publish as PublishGen
  29. from autobahn.wamp.gen.wamp.proto import Message
  30. from autobahn.wamp.gen.wamp.proto.MessageType import MessageType
  31. __all__ = (
  32. 'Event',
  33. 'Message',
  34. 'MessageType',
  35. )
  36. class Event(EventGen.Event):
  37. @classmethod
  38. def GetRootAsEvent(cls, buf, offset):
  39. n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
  40. x = Event()
  41. x.Init(buf, n + offset)
  42. return x
  43. def Init(self, buf, pos):
  44. self._tab = flatbuffers.table.Table(buf, pos)
  45. def ArgsAsBytes(self):
  46. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
  47. if o != 0:
  48. _off = self._tab.Vector(o)
  49. _len = self._tab.VectorLen(o)
  50. return memoryview(self._tab.Bytes)[_off:_off+_len]
  51. return None
  52. def KwargsAsBytes(self):
  53. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
  54. if o != 0:
  55. _off = self._tab.Vector(o)
  56. _len = self._tab.VectorLen(o)
  57. return memoryview(self._tab.Bytes)[_off:_off+_len]
  58. return None
  59. def PayloadAsBytes(self):
  60. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
  61. if o != 0:
  62. _off = self._tab.Vector(o)
  63. _len = self._tab.VectorLen(o)
  64. return memoryview(self._tab.Bytes)[_off:_off+_len]
  65. return None
  66. def EncKeyAsBytes(self):
  67. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
  68. if o != 0:
  69. _off = self._tab.Vector(o)
  70. _len = self._tab.VectorLen(o)
  71. return memoryview(self._tab.Bytes)[_off:_off+_len]
  72. return None
  73. class Publish(PublishGen.Publish):
  74. @classmethod
  75. def GetRootAsEvent(cls, buf, offset):
  76. n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
  77. x = Event()
  78. x.Init(buf, n + offset)
  79. return x
  80. def Init(self, buf, pos):
  81. self._tab = flatbuffers.table.Table(buf, pos)
  82. def ArgsAsBytes(self):
  83. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
  84. if o != 0:
  85. _off = self._tab.Vector(o)
  86. _len = self._tab.VectorLen(o)
  87. return memoryview(self._tab.Bytes)[_off:_off+_len]
  88. return None
  89. def KwargsAsBytes(self):
  90. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
  91. if o != 0:
  92. _off = self._tab.Vector(o)
  93. _len = self._tab.VectorLen(o)
  94. return memoryview(self._tab.Bytes)[_off:_off+_len]
  95. return None
  96. def PayloadAsBytes(self):
  97. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
  98. if o != 0:
  99. _off = self._tab.Vector(o)
  100. _len = self._tab.VectorLen(o)
  101. return memoryview(self._tab.Bytes)[_off:_off+_len]
  102. return None
  103. def EncKeyAsBytes(self):
  104. o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
  105. if o != 0:
  106. _off = self._tab.Vector(o)
  107. _len = self._tab.VectorLen(o)
  108. return memoryview(self._tab.Bytes)[_off:_off+_len]
  109. return None