Example #1
0
 def callServerMethod(self, methodName, parameters=None, entityId=None):
     if entityId is None:
         entityId = self.getOwnerId()
         if entityId is None:
             self.logger.error('callServerMethod: did not find owner %s, need pass entityId to call %s', str(self.owner), methodName)
             return
     entityRpc = EntityRpc()
     entityRpc.id = IdCreator.id2bytes(entityId)
     self.encoder.encode(entityRpc.method, methodName)
     if parameters is not None:
         if self.proto == 'BSON' or self.proto == 'bson':
             entityRpc.arguments = BSON.encode(parameters)
         elif self.proto == 'msgpack':
             entityRpc.arguments = msgpack.packb(parameters, use_bin_type=True, default=msgPackExt)
     self.stub.entityRpc(None, entityRpc)