Skip to content

Instantly share code, notes, and snippets.

@bbenzinger
Created March 30, 2015 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbenzinger/8f2b583e29759589df9e to your computer and use it in GitHub Desktop.
Save bbenzinger/8f2b583e29759589df9e to your computer and use it in GitHub Desktop.
InvalidCallbackException when setting authenticator from MetaCallback
#!/usr/bin/env python
# -*- coding: utf-8
import Ice, sys, time
Ice.loadSlice('', ['-I' + Ice.getSliceDir(), 'Murmur.ice'])
import Murmur
class MetaCallbackI(Murmur.MetaCallback):
def started(self, server, current=None):
print "From MetaCallbackI : Attaching callbacks to virtual server %d." % server.id()
print "... Attaching server callbacks"
serverR=Murmur.ServerCallbackPrx.uncheckedCast(current.adapter.addWithUUID(ServerCallbackI()))
server.addCallback(serverR)
print "... Attaching authenticator callbacks"
authR=Murmur.ServerUpdatingAuthenticatorPrx.uncheckedCast(current.adapter.addWithUUID(ServerAuthenticatorI()))
server.setAuthenticator(authR)
def stopped(self, server, current=None):
pass
class ServerAuthenticatorI(Murmur.ServerUpdatingAuthenticator):
def authenticate(self, name, pw, certlist, certhash, strong, current=None):
groups = ("GroupA", "GroupB");
if (name == "One"):
if (pw == "Magic"):
return (1, "One", groups)
else:
return (-1, None, None)
return (-2, None, None)
def getInfo(self, id, current=None):
print "getInfo ", id
return (False, {})
def nameToId(self, name, current=None):
return -2;
def idToName(self, id, current=None):
return None
def idToTexture(self, id, current=None):
print "idToTexture", id
return None
def registerUser(self, name, current=None):
print "Someone tried to register ", name
return -2
def unregisterUser(self, id, current=None):
print "Unregister ", id
return -2
def getRegistration(self, id, current=None):
return (-2, None, None)
def setInfo(self, id, info, current=None):
print "Set", id, info
return -1
def setTexture(self, id, texture, current=None):
print "Texture", id
return -1
class ServerCallbackI(Murmur.ServerCallback):
def userConnected(self, state, current=None):
print"userConnected ", state.userid
pass
def userDisconnected(self, state, current=None):
print"userDisconnected ", state.userid
pass
def userStateChanged(self, state, current=None):
print"userStateChanged ", state.userid
pass
def userTextMessage(self, state, message, current=None):
print"userTextMessage ", state.userid
pass
def channelCreated(self, state, current=None):
print"channelCreated ", state.id
pass
def channelRemoved(self, state, current=None):
print"channelRemoved ", state.id
pass
def channelStateChanged(self, state):
print"channelStateChanged ", state.id
pass
if __name__ == "__main__":
print "Creating callbacks..."
init_data = Ice.InitializationData()
init_data.properties = Ice.createProperties([])
init_data.properties.setProperty("Ice.ImplicitContext", "Shared")
init_data.properties.setProperty("Ice.Default.EncodingVersion", "1.0")
ice = Ice.initialize(init_data)
ice.getImplicitContext().put("secret", "secret")
meta = Murmur.MetaPrx.checkedCast(ice.stringToProxy('Meta:tcp -h 127.0.0.1 -p 6502'))
adapter = ice.createObjectAdapterWithEndpoints("Callback.Client", "tcp -h 127.0.0.1")
adapter.activate()
metaR=Murmur.MetaCallbackPrx.uncheckedCast(adapter.addWithUUID(MetaCallbackI()))
meta.addCallback(metaR)
for server in meta.getBootedServers():
print "Attaching callbacks to virtual server %d running Mumble" % server.id()
serverR=Murmur.ServerCallbackPrx.uncheckedCast(adapter.addWithUUID(ServerCallbackI()))
server.addCallback(serverR)
authR=Murmur.ServerUpdatingAuthenticatorPrx.uncheckedCast(adapter.addWithUUID(ServerAuthenticatorI()))
server.setAuthenticator(authR)
try:
ice.waitForShutdown()
except KeyboardInterrupt:
print "CTRL-C caught, aborting"
meta.removeCallback(metaR)
ice.shutdown()
print "Goodbye"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment