Example #1
0
    private void runIdTest()
    {
        Console.WriteLine("Hello world");
        xb = XmlBlasterAccessFactory.CreateInstance();
        xb.AddLoggingListener(this);
        xb.Initialize(argv);
        log("Accessing not IDs");
        string deviceId = xb.GetDeviceUniqueId();

        log("deviceId=" + deviceId);
        //MessageBox.Show("DeviceUniqueId="+deviceId, "Name Entry Error",
        //   MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
        string emeiId = xb.GetEmeiId();

        log("EMEI=" + emeiId);
        //MessageBox.Show("EMEI="+emeiId, "Name Entry Error",
        //   MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
    }
Example #2
0
    public Hello(string[] argv)
    {
        I_XmlBlasterAccess nc = XmlBlasterAccessFactory.CreateInstance();

        nc.Initialize(argv);
        nc.Initialize(new Hashtable());
        nc.RegisterConnectionListener(this);

        string connectQos = String.Format(
            "<qos>\n" +
            " <securityService type='htpasswd' version='1.0'>\n" +
            "  <![CDATA[\n" +
            "   <user>fritz</user>\n" +
            "   <passwd>secret</passwd>\n" +
            "  ]]>\n" +
            " </securityService>\n" +
            " <queue relating='callback' maxEntries='50000' maxEntriesCache='10000'>\n" +
            "   <callback type='SOCKET' sessionId='{0}'>\n" +
            "   </callback>\n" +
            " </queue>\n" +
            "</qos>", callbackSessionId); //"    socket://{1}:{2}"+

        Console.WriteLine("Connecting with:" + connectQos);

        I_Callback       callback = this;
        ConnectReturnQos qos      = nc.Connect(connectQos, callback);

        Console.WriteLine("Connected." + qos.GetSessionName());

        for (int i = 0; i < 5; i++)
        {
            SubscribeReturnQos srq = nc.Subscribe("<key oid='Hello'/>", "<qos/>");
            Console.WriteLine("subscribe() returned " + srq.GetSubscriptionId());

            //nc.publish("<key oid='Hello'/>", "HIII", "<qos/>");
            PublishReturnQos prq = nc.Publish("<key oid='C#C#C#'/>", "HIIIHAAAA", "<qos/>");
            Console.WriteLine("publish() returned " + prq.GetKeyOid());

            prq = nc.Publish("<key oid='C#C#C#'/>", "HIIIHOOO", "<qos/>");
            Console.WriteLine("publish() returned " + prq.GetKeyOid());

            MsgUnitGet[] msgs = nc.Get("<key oid='C#C#C#'/>", "<qos><history numEntries='6'/></qos>");
            Console.WriteLine("get() returned " + msgs.Length + " messages");

            string p = nc.Ping("<qos/>");
            Console.WriteLine("ping() returned " + p);

            bool b = nc.IsConnected();
            Console.WriteLine("isConnected() returned " + b);

            UnSubscribeReturnQos[] urq = nc.UnSubscribe("<key oid='Hello'/>", "<qos/>");
            Console.WriteLine("unSubscribe() returned " + urq[0].GetSubscriptionId());

            EraseReturnQos[] erq = nc.Erase("<key oid='C#C#C#'/>", "<qos/>");
            Console.WriteLine("erase() returned " + erq[0].GetKeyOid());

            Console.WriteLine("\nHit a key " + i);
            Console.ReadLine();
        }
        bool drq = nc.Disconnect("<qos/>");

        Console.WriteLine("disconnect() returned " + drq);

        Console.WriteLine("DONE");
    }
Example #3
0
    private void runAllMethods()
    {
        xb = XmlBlasterAccessFactory.CreateInstance();
        xb.AddLoggingListener(this);
        xb.Initialize(argv);
        xb.Initialize(new Hashtable());

        string connectQos = String.Format(
            "<qos>\n" +
            " <securityService type='htpasswd' version='1.0'>\n" +
            "  <![CDATA[\n" +
            "   <user>fritz</user>\n" +
            "   <passwd>secret</passwd>\n" +
            "  ]]>\n" +
            " </securityService>\n" +
            " <queue relating='callback' maxEntries='50000' maxEntriesCache='10000'>\n" +
            "   <callback type='SOCKET' sessionId='{0}'>\n" +
            "   </callback>\n" +
            " </queue>\n" +
            "</qos>", callbackSessionId); //"    socket://{1}:{2}"+

        log("Connecting with:" + connectQos);

        I_Callback callback = this;

        xb.Connect(connectQos, callback);
        xb.AddCallbackProgressListener(this);

        for (int run = 0; run < 2; run++)
        {
            PublishReturnQos prq = xb.Publish("<key oid='Hello'/>", "publish-1", "<qos/>");
            log("publish() returned " + prq.GetKeyOid());

            SubscribeReturnQos srq = xb.Subscribe("<key oid='Hello'/>", "<qos><updateOneway/></qos>");
            log("subscribe() returned " + srq.GetSubscriptionId());
            GC.Collect();
            GC.Collect();

            prq = xb.Publish("<key oid='Hello'/>", "publish-2", "<qos/>");
            log("publish() returned " + prq.GetKeyOid());

            Thread.Sleep(1000);
            Console.WriteLine("There should be some updates, hit a key to continue ...");
            Console.ReadLine();

            srq = xb.Subscribe("<key oid='TestPInvoke'/>", "<qos/>");
            log("subscribe() returned " + srq.GetSubscriptionId());

            srq = xb.Subscribe("<key oid='TestPInvoke'/>", "<qos/>");
            log("subscribe() returned " + srq.GetSubscriptionId());

            UnSubscribeReturnQos[] urq = xb.UnSubscribe("<key oid='TestPInvoke'/>", "<qos/>");
            log("unSubscribe() returned");
            for (int i = 0; i < urq.Length; i++)
            {
                log("unSubscribeReturn #" + i + ": " + urq[i].GetSubscriptionId());
            }
            GC.Collect();
            GC.Collect();

            prq = xb.Publish("<key oid='C#C#C#'/>", "more publishes", "<qos/>");
            log("publish() returned " + prq.GetKeyOid());

            MsgUnit[] arr = new MsgUnit[6];
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = new MsgUnit("<key oid='C#C#'/>", "oneway-" + i, "<qos/>");
            }
            xb.PublishOneway(arr);
            log("publishOneway() send " + arr.Length + " messages");

            prq = xb.Publish("<key oid='C#'/>", "HIIIHAAAA", "<qos/>");
            log("publish() returned " + prq.GetRcvTimeNanos());

            MsgUnit[] msgs = xb.Get("<key oid='C#C#'/>", "<qos><history numEntries='4'/></qos>");
            log("get(C#C#) returned " + msgs.Length + " messages (get was limited to 4)");
            for (int i = 0; i < msgs.Length; i++)
            {
                log(msgs[i].ToString());
            }

            msgs = xb.Get("<key oid='unknown'/>", "<qos><history numEntries='6'/></qos>");
            log("get(unknown) returned " + msgs.Length + " messages");

            EraseReturnQos[] erq = xb.Erase("<key queryType='XPATH'>//key</key>", "<qos/>");
            log("erase() returned");
            for (int i = 0; i < erq.Length; i++)
            {
                log("eraseReturn #" + i + ": " + erq[i].GetKeyOid());
            }

            string    p  = xb.Ping("<qos/>");
            StatusQos pp = new StatusQos(p);
            log("ping() returned " + pp.GetState());

            bool b = xb.IsConnected();
            log("isConnected() returned " + b);
        }

        bool drq = xb.Disconnect("<qos/>");

        log("disconnect() returned " + drq);

        log("DONE");
    }