Exemplo n.º 1
0
 def _HandleExtensionMessage(self, message):
     if message is None or not isinstance(
             message, Multiverse.Network.ExtensionMessage):
         return
     extensionType = None
     if message.Properties.ContainsKey("ext_msg_subtype"):
         extensionType = message.Properties["ext_msg_subtype"]
     elif message.Properties.ContainsKey("ext_msg_type"):
         ClientAPI._deprecated("1.1",
                               "Extension message with 'ext_msg_type'",
                               "Extension message with 'ext_msg_subtype'")
         extensionType = message.Properties["ext_msg_type"]
     else:
         ClientAPI.LogWarn("Received extension message without a subtype")
         return
     if self._extensionHandlers.has_key(extensionType):
         message.Properties["ext_msg_subject_oid"] = message.Oid
         message.Properties["ext_msg_target_oid"] = message.TargetOid
         message.Properties[
             "ext_msg_client_targeted"] = message.ClientTargeted
         handlers = self._extensionHandlers[extensionType]
         for handler in handlers:
             handler(
                 Multiverse.Network.PropertyMap.ToPythonDict(
                     message.Properties))
Exemplo n.º 2
0
def RegisterEventHandler(eventName, eventHandler):
    """Register a method that will receive all ui events.  The method will be
       invoked with two arguments; the eventType and an array of strings."""
    global _uiEventHandlers
    if eventName == 'UiEvent':
        if eventHandler in _uiEventHandlers:
            ClientAPI.LogError("Duplicate add of event handler")
        _uiEventHandlers.append(eventHandler)
    else:
        ClientAPI.LogError(
            "Invalid event name '%s' passed to Interface.RegisterEventHandler"
            % str(eventName))
Exemplo n.º 3
0
 def QueueAnimationExt(self,
                       animation,
                       startOffset=0.0,
                       endOffset=0.0,
                       speed=1.0,
                       weight=1.0,
                       looping=False):
     """
     @deprecated: Use WorldObject.QueueAnimation()
     """
     ClientAPI._deprecated("1.1", "WorldObject.QueueAnimationExt()",
                           "WorldObject.QueueAnimation")
     return self.QueueAnimation(animation, speed, looping, startOffset,
                                endOffset, weight)
Exemplo n.º 4
0
 def GetCharacterAttributes(self, characterId):
     """Fetch a dictionary containing a copy of the attributes sent from
        the server for the character with characterId."""
     for charEntry in ClientAPI.GetCharacterEntries():
         if charEntry.CharacterId == characterId:
             return charEntry
     return None
Exemplo n.º 5
0
def SpeakerBlacklisted(speakerOid):
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't call SpeakerBlacklisted")
        return False
    else:
        return _worldManager.VoiceMgr.SpeakerBlacklisted(speakerOid)
Exemplo n.º 6
0
def ConfigureVoiceManager(args, connectedToVoiceServer):
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't be configured")
    else:
        _worldManager.VoiceMgr = VoiceManager.Reconfigure(
            _worldManager.VoiceMgr, args, connectedToVoiceServer)
Exemplo n.º 7
0
def GetPlaybackVolume(speakerOid):
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't call GetPlaybackVolume")
        return 0.0
    else:
        return _worldManager.VoiceMgr.GetPlaybackVolume(speakerOid)
Exemplo n.º 8
0
def SetPlaybackVolumeForAllSpeakers(level):
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't call SetPlaybackVolumeForAllSpeakers"
        )
    else:
        _worldManager.VoiceMgr.SetPlaybackVolumeForAllSpeakers(level)
Exemplo n.º 9
0
def RecentSpeakers():
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't call SetMicLevel")
        return None
    else:
        return _worldManager.VoiceMgr.RecentSpeakers()
Exemplo n.º 10
0
def GetMicNumber():
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't call GetMicNumber")
        return None
    else:
        return _worldManager.VoiceMgr.GetMicNumber()
Exemplo n.º 11
0
def main():
    client = ClientAPI.Client()

    # Read config file
    try:
        client.readConfig()
    except KeyError:
        print('Config file found error, Please check your config file')
        exit(0)

    # Register to server TODO: Merge in sendHeartbeat
    try:
        client.register()
    except urllib.error.URLError:
        print(
            'Can not get response from server, Please check you serverLocation settings'
        )
        exit(0)

    # Unless loop end Heartbeat
    while True:
        try:
            client.sendHeartbeat()
        except urllib.error.URLError:
            print('Network Error, Will continue resend Heartbeat')
        time.sleep(10)
Exemplo n.º 12
0
def GetAllPlaybackDevices():
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't call GetAllPlaybackDevices"
        )
        return None
    else:
        return _worldManager.VoiceMgr.GetAllPlaybackDevices()
Exemplo n.º 13
0
def GetBlacklistedSpeakers():
    if _worldManager.VoiceMgr == None:
        ClientAPI.Write(
            "WorldManager.VoiceMgr is null, so can't call GetBlacklistedSpeakers"
        )
        return None
    else:
        return _worldManager.VoiceMgr.GetBlacklistedSpeakers()
Exemplo n.º 14
0
def DispatchEvent(eventType, eventArgs):
    # First dispatch to the global handlers
    # note that a few events are not inserted this way, and will not be
    # handled by the global handlers, since they come from client C# code.
    global _uiEventHandlers
    for handler in _uiEventHandlers:
        try:
            handler(eventType, eventArgs)
        except Exception, e:
            ClientAPI.LogError("UiEvent Handler Error: " + str(e))
Exemplo n.º 15
0
 def _HandleExtensionMessage(self, message):
     if message is None or not isinstance(message, Multiverse.Network.ExtensionMessage):
         return
     extensionType = None
     if message.Properties.ContainsKey("ext_msg_subtype"):
         extensionType = message.Properties["ext_msg_subtype"]
     elif message.Properties.ContainsKey("ext_msg_type"):
         ClientAPI._deprecated("1.1", "Extension message with 'ext_msg_type'",
                               "Extension message with 'ext_msg_subtype'")
         extensionType = message.Properties["ext_msg_type"]
     else:
         ClientAPI.LogWarn("Received extension message without a subtype")
         return
     if self._extensionHandlers.has_key(extensionType):
         message.Properties["ext_msg_subject_oid"] = message.Oid
         message.Properties["ext_msg_target_oid"] = message.TargetOid
         message.Properties["ext_msg_client_targeted"] = message.ClientTargeted
         handlers = self._extensionHandlers[extensionType]
         for handler in handlers:
             handler(Multiverse.Network.PropertyMap.ToPythonDict(message.Properties))
Exemplo n.º 16
0
def RemoveEventHandler(eventName, eventHandler):
    """Remove a method that was previously registered to receive all ui
       events."""
    global _uiEventHandlers
    if eventName == 'UiEvent':
        if eventHandler in _uiEventHandlers:
            _uiEventHandlers.remove(eventHandler)
    else:
        ClientAPI.LogError(
            "Invalid event name '%s' passed to Interface.RemoveEventHandler" %
            str(eventName))
Exemplo n.º 17
0
 def SendTradeOffer(self, partnerId, itemIds, accepted, cancelled):
     items = System.Collections.Generic.List[System.Int64]()
     for i in itemIds:
         items.Add(i)
     message = Multiverse.Network.TradeOfferRequestMessage()
     message.Oid = ClientAPI.GetPlayerObject().OID
     message.ObjectId = partnerId
     message.Accepted = accepted
     message.Cancelled = cancelled
     message.Offer = items
     self.SendMessage(message)
Exemplo n.º 18
0
 def RemoveEventHandler(self, eventName, eventHandler):
     if eventName == 'WorldInitialized':
         Multiverse.Base.ClientAPI.WorldInitialized -= eventHandler
     elif eventName == 'ObjectAdded':
         del self._objectAddedHandlers[_objectAddedHandlers.index(eventHandler)]
     elif eventName == 'ObjectRemoved':
         del self._objectRemovedHandlers[_objectRemovedHandlers.index(eventHandler)]
     elif eventName == 'AmbientLightChanged':
         self._sceneManager.AmbientLightChanged -= eventHandler
     elif eventName == 'LightAdded':
         self._sceneManager.LightAdded -= eventHandler
     elif eventName == 'LightRemoved':
         self._sceneManager.LightRemoved -= eventHandler
     elif eventName == 'LoadingStateChanged':
         self._worldManager.OnLoadingStateChange -= eventHandler
     else:
         ClientAPI.LogError("Invalid event name '%s' passed to World.RemoveEventHandler" % str(eventName))
Exemplo n.º 19
0
 def Execute(self):
     results = self._rayQuery.Execute()
     rv = []
     for entry in results:
         if entry.SceneObject is not None:
             if isinstance(entry.SceneObject.UserData,
                           Multiverse.Base.ObjectNode):
                 existingObject = WorldObject._GetExistingWorldObject(
                     entry.SceneObject.UserData)
                 rv.append(
                     RaySceneQueryResult(entry.Distance, existingObject,
                                         None))
             else:
                 ClientAPI.Write("Skipping non-multiverse object: %s" %
                                 entry.SceneObject.UserData)
                 # ignore this object
                 pass
         elif entry.worldFragment is not None:
             rv.append(
                 RaySceneQueryResult(
                     entry.Distance, None,
                     entry.worldFragment.SingleIntersection))
     return rv
Exemplo n.º 20
0
 def QueueAnimationExt(self, animation, startOffset=0.0, endOffset=0.0, speed=1.0, weight=1.0, looping=False):
     """
     @deprecated: Use WorldObject.QueueAnimation()
     """
     ClientAPI._deprecated("1.1", "WorldObject.QueueAnimationExt()", "WorldObject.QueueAnimation")
     return self.QueueAnimation(animation, speed, looping, startOffset, endOffset, weight)
Exemplo n.º 21
0
import clr
import System
import ClientAPI

ClientAPI.Log("Current Directory: %s" % System.Environment.CurrentDirectory)
clr.AddReferenceToFileAndPath("%s/mvVoiceCLR.dll" %
                              System.Environment.CurrentDirectory)
import mvVoiceCLR

connectorID = ""
accountID = ""
sessionID = ""
server = "http://www.vd1.vivox.com/api2"
username = "******"
password = "******"
channel = "sip:[email protected]"


def mvVoiceInit():
    global connectorID
    global accountID
    mvVoiceCLR.VoiceCLR.Init(server)
    connectorID = mvVoiceCLR.VoiceCLR.GetConnectorID()
    mvVoiceCLR.VoiceCLR.Login(connectorID, username, password)
    accountID = mvVoiceCLR.VoiceCLR.GetAccountID()
    mvVoiceCLR.VoiceCLR.MicMute(connectorID, True)


def mvVoiceOn():
    global sessionID
    mvVoiceCLR.VoiceCLR.Call(accountID, channel)
Exemplo n.º 22
0
def RunScript(args_str):
    try:
        Multiverse.Interface.UiScripting.RunScript(args_str)
    except Exception, e:
        ClientAPI.Write("Script Error: " + str(e))
Exemplo n.º 23
0
size = width, height = 6400, 4800

if "-v" in sys.argv:
    import pygame
    pygame.init()
    basicFont = pygame.font.SysFont(None, 24)
    SCALEFACTOR = 640 / width
    screen = pygame.display.set_mode(
        (int(width * SCALEFACTOR), int(height * SCALEFACTOR)))

universe = Universe.Universe(size)
universe.id = 0

network = NetworkServer.NetworkServer({}, universe)

api = ClientAPI.ClientAPI(ClientAPI.GlobalContext([universe], network))

# Register ALL the classes!
api.register(Universe.Universe)
api.register(Entity.Entity)
api.register(Ship.Ship)
api.register(Component.Component)
api.register(Component.Drive)
api.register(Component.WeaponsStation)
api.register(Component.ShieldGenerator)
api.register(SharedClientDataStore.SharedClientDataStore)
api.register(Client.ClientUpdater)

print(api.getTable())

network.start(api)
Exemplo n.º 24
0
 def _set_FollowTerrain(self, value):
     ClientAPI.GetPlayerObject()._objectNode.FollowTerrain = value
Exemplo n.º 25
0
 def _get_FollowTerrain(self):
     return ClientAPI.GetPlayerObject()._objectNode.FollowTerrain
Exemplo n.º 26
0
 def InvokeEffect(self, effectName, oid, args):
     ClientAPI.DebugLog("Invoking Effect " + effectName)
     instance = self._effects[effectName](oid)
     ret = instance.ExecuteEffect(**args)
     if ret != None:
         Multiverse.Base.ClientAPI.QueueYieldEffect(ret, 0)            
Exemplo n.º 27
0
 def GetTerrainHeight(self, x, z):
     return self._worldManager.GetHeightAt(ClientAPI.Vector3(x, 0, z))
Exemplo n.º 28
0
 def GetTerrainHeightVector(self, v):
     return ClientAPI.Vector3(v.x, self._worldManager.GetHeightAt(v), v.z)    
Exemplo n.º 29
0
            elif serial:
                self.id = serial[0]

        def serialized(self):
            return self.id,

        def instance(self, global_context):
            return things[self.id]

    def __init__(self, id, name):
        self.id = id
        self.name = name
        things[id] = self

    @expose
    def do_thing(self):
        print("Hi! I'm {} (ID {})".format(self.name, self.id))

    def dont_expose(self):
        print("I shouldn't be called!")

api = ClientAPI(None)

bob = Thing(1, "Bob")

api.register(Thing)
api.onCall('Thing.do_thing', (1,))
print("name is {}".format(api.onGet('Thing.name', (1,))))
api.onSet('Thing.name', (1,), "not bob")
print("name is {}".format(api.onGet('Thing.name', (1,))))
Exemplo n.º 30
0
 def RegisterEffect(self, effectName, effectFunc):
     ClientAPI.DebugLog("Registering Effect " + effectName)
     self._effects[effectName] = effectFunc
Exemplo n.º 31
0
 def _set_Near(self, near):
     if self._camera is None:
         ClientAPI.Log("_set_Near: camera is None")
     self._camera.Near = near
Exemplo n.º 32
0
 def SetLoadingScreenVisible(self, visible):
     ClientAPI.LogDebug("World.py: Setting loading screen visible '%s'" % str(visible))
     ClientAPI._client.LoadWindowVisible = visible
Exemplo n.º 33
0
                self.id = serial[0]

        def serialized(self):
            return self.id,

        def instance(self, global_context):
            return things[self.id]

    def __init__(self, id, name):
        self.id = id
        self.name = name
        things[id] = self

    @expose
    def do_thing(self):
        print("Hi! I'm {} (ID {})".format(self.name, self.id))

    def dont_expose(self):
        print("I shouldn't be called!")


api = ClientAPI(None)

bob = Thing(1, "Bob")

api.register(Thing)
api.onCall('Thing.do_thing', (1, ))
print("name is {}".format(api.onGet('Thing.name', (1, ))))
api.onSet('Thing.name', (1, ), "not bob")
print("name is {}".format(api.onGet('Thing.name', (1, ))))