示例#1
0
def main(argv):
    msg_arg = 3.141592654

    matecomponent.activate()

    app = matecomponent.Application("Libmatecomponent-Test-Uniqapp")

    app.register_message(CLOSURE_MESSAGE, "This is a test message", float,
                         (int, float), closure_message_cb, "user-data")

    client = app.register_unique(app.create_serverinfo(("LANG", )))
    if client is not None:
        print "I am an application client."
        app.unref()
        del app

        msgdescs = client.msg_list()
        for msgdesc in msgdescs:
            print "Application supports message:", msgdesc

        print "Sending message string '%s' with argument %f" % (TEST_MESSAGE,
                                                                msg_arg)
        retval = client.msg_send(TEST_MESSAGE, (msg_arg, "this is a string"))
        print "Return value:", retval

        print "Sending message string '%s' with arguments %i and %f" % (
            CLOSURE_MESSAGE, 10, 3.141592654)
        retval = client.msg_send(CLOSURE_MESSAGE, (10, 3.141592654))
        print "Return value: ", retval

        print "Sending new-instance, with argv"
        i = client.new_instance(argv)
        print "new-instance returned ", i

        print "Asking the server to quit"
        client.msg_send("quit", ())
        return
    else:
        print "I am an application server"
        app.connect("message::test-message", message_cb)
        app.connect("new-instance", new_instance_cb)
        app.new_instance(argv)
        app.connect("message::quit", message_quit_cb)

        matecomponent.main()
        app.unref()
def main(argv):
    msg_arg = 3.141592654

    matecomponent.activate()

    app = matecomponent.Application("Libmatecomponent-Test-Uniqapp")

    app.register_message(
        CLOSURE_MESSAGE, "This is a test message", float, (int, float), closure_message_cb, "user-data"
    )

    client = app.register_unique(app.create_serverinfo(("LANG",)))
    if client is not None:
        print "I am an application client."
        app.unref()
        del app

        msgdescs = client.msg_list()
        for msgdesc in msgdescs:
            print "Application supports message:", msgdesc

        print "Sending message string '%s' with argument %f" % (TEST_MESSAGE, msg_arg)
        retval = client.msg_send(TEST_MESSAGE, (msg_arg, "this is a string"))
        print "Return value:", retval

        print "Sending message string '%s' with arguments %i and %f" % (CLOSURE_MESSAGE, 10, 3.141592654)
        retval = client.msg_send(CLOSURE_MESSAGE, (10, 3.141592654))
        print "Return value: ", retval

        print "Sending new-instance, with argv"
        i = client.new_instance(argv)
        print "new-instance returned ", i

        print "Asking the server to quit"
        client.msg_send("quit", ())
        return
    else:
        print "I am an application server"
        app.connect("message::test-message", message_cb)
        app.connect("new-instance", new_instance_cb)
        app.new_instance(argv)
        app.connect("message::quit", message_quit_cb)

        matecomponent.main()
        app.unref()
示例#3
0
#! /usr/bin/env python
import pygtk; pygtk.require("2.0")

import matecomponent
import MateComponent
import MateComponent__POA
import CORBA, sys
import gc

gc.set_debug(gc.DEBUG_LEAK)

orb = CORBA.ORB_init(sys.argv)
matecomponent.activate()

class PersistStream(MateComponent__POA.PersistStream, matecomponent.UnknownBaseImpl):
    def __init__(self):
        matecomponent.UnknownBaseImpl.__init__(self)

    # implementations of methods/attributes of "Interface" go here

    def load(self, content_type):
	print "PersistStream::load(content_type='%s')" % content_type

    def save(self, content_type):
	print "PersistStream::save(content_type='%s')" % content_type


ps = PersistStream()

def foo(*args):
    print args
import matecomponent
import MateComponent

matecomponent.activate ()

obj = matecomponent.get_object ('OAFIID:MateComponent_Sample_Echo', 'MateComponent/Sample/Echo')
obj.echo ('This is the message from the python client\n')