How to raise function of some object in script.

I create some object in script:

Qt Code:
  1. QScriptValue socket_ctor(QScriptContext *context, QScriptEngine *engine)
  2. {
  3. QString ip;
  4. quint16 port;
  5.  
  6. ip = context->argument(0).toString();
  7. port = context->argument(1).toUInt16();
  8.  
  9. Server* ss=new Server(ip ,port);
  10. QScriptValue sw = engine->newQObject( ss , QScriptEngine::ScriptOwnership);
  11.  
  12. return sw;
  13.  
  14. }
  15.  
  16. QScriptValue socket = myEngine.newFunction(socket_ctor);
  17. myEngine.globalObject().setProperty("socket", socket);
To copy to clipboard, switch view to plain text mode 



How to launch some function (like: onConnect()) without using word 'connect' in this context, when my server get connected?
Qt Code:
  1. var sck=socket("localhost",1200);
  2. sck.onConnect () {
  3. .../do something - user defined handler for this event
  4. }
To copy to clipboard, switch view to plain text mode 

I now how to launch 'global' function (which belongs no object), but how use it when function belongs to my object.

I repeate , i now how use it with word 'connect' with connecting c++ signal with script`s slot, but how just launch function?
Sorry for my english and thanx for answers...