Beispiel #1
0
    public static void Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("Usage: SimpleDequeuer <qspace> <qname>");
            Environment.Exit(1);
        }

        string qSpace = args[0];
        string qName  = args[1];

        ATMI.tpinit(null);
        try
        {
            ByteBuffer data = ATMI.tpalloc("STRING", null, 512);
            try
            {
                TPQCTL ctl = new TPQCTL();
                ctl.flags = ATMI.TPQWAIT;
                int len;
                ATMI.tpdequeue(qSpace, qName, ctl, ref data, out len, 0);
                string message = StringUtils.ReadStringBuffer(data, len);
                Console.WriteLine("Dequeued '" + message + "' from " + qSpace + "." + qName);
            }
            finally
            {
                ATMI.tpfree(data);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Beispiel #2
0
    public static void Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("Usage: UnsolClient <service> <message>");
            Environment.Exit(1);
        }

        string service = args[0];
        string message = args[1];

        TPINIT tpinfo = new TPINIT();

        tpinfo.cltname = "sample";

        ATMI.tpinit(tpinfo);
        try
        {
            ATMI.tpsetunsol(new UnsolHandler(tpunsol));
            try
            {
                ByteBuffer data = StringUtils.NewStringBuffer(message);
                try
                {
                    Console.WriteLine("Sending '" + message + "' to service " + service);
                    int cd = ATMI.tpacall(service, data, 0, 0);

                    WaitForMessages(10);

                    int len;
                    ATMI.tpgetrply(ref cd, ref data, out len, 0);
                    message = StringUtils.ReadStringBuffer(data, len);
                    Console.WriteLine("Returned string is: " + message);
                }
                finally
                {
                    ATMI.tpfree(data);
                }
            }
            finally
            {
                ATMI.tpsetunsol(null);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Beispiel #3
0
    public static void Main(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine("Usage: SimpleAsyncClient <message>");
            Environment.Exit(1);
        }

        string message = args[0];

        ATMI.tpinit(null);
        try
        {
            int        cd;
            ByteBuffer sendbuf = StringUtils.NewStringBuffer(message);
            try
            {
                Console.WriteLine("Sending '" + message + "' to service TOUPPER");
                cd = ATMI.tpacall("TOUPPER", sendbuf, 0, 0);
            }
            finally
            {
                ATMI.tpfree(sendbuf);
            }

            ByteBuffer rcvbuf = ATMI.tpalloc("STRING", null, 256);
            try
            {
                int rcvlen;
                ATMI.tpgetrply(ref cd, ref rcvbuf, out rcvlen, 0);
                message = StringUtils.ReadStringBuffer(rcvbuf, rcvlen);
                Console.WriteLine("Returned string is: " + message);
            }
            finally
            {
                ATMI.tpfree(rcvbuf);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Beispiel #4
0
    public static void Main(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine("Usage: SimpleClient <message>");
            Environment.Exit(1);
        }

        string message = args[0];

        ATMI.tpinit(null);
        try
        {
            byte[]     bytes   = Encoding.Default.GetBytes(message);
            int        sendlen = bytes.Length + 1; // One byte extra for terminating zero
            ByteBuffer sendbuf = ATMI.tpalloc("STRING", null, sendlen);
            try
            {
                ByteBuffer rcvbuf = ATMI.tpalloc("STRING", null, sendlen);
                try
                {
                    sendbuf.PutBytes(bytes);
                    sendbuf.PutByte(bytes.Length, 0); // Terminating zero
                    int rcvlen;
                    ATMI.tpcall("TOUPPER", sendbuf, 0, ref rcvbuf, out rcvlen, 0);
                    rcvbuf.GetBytes(bytes);
                    Console.WriteLine("Returned string is: " + Encoding.Default.GetString(bytes));
                }
                finally
                {
                    ATMI.tpfree(rcvbuf);
                }
            }
            finally
            {
                ATMI.tpfree(sendbuf);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Beispiel #5
0
 public static void Main(string[] args)
 {
     ATMI.tpinit(null);
     try {
         ByteBuffer reply = ATMI.tpalloc("STRING", null, 1024);
         try {
             int len;
             ATMI.tpcall("TEST", null, 0, ref reply, out len, 0);
             byte[] bytes = new byte[len - 1];
             reply.GetBytes(bytes);
             string message = Encoding.Default.GetString(bytes);
             Console.WriteLine(message);
         } finally {
             ATMI.tpfree(reply);
         }
     } finally {
         ATMI.tpterm();
     }
 }
Beispiel #6
0
    public static void Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("Usage: DownloadClient <remote file> <local file>");
            Environment.Exit(1);
        }

        string remoteFileName = args[0];
        string localFileName  = args[1];

        ATMI.tpinit(null);
        try
        {
            Conversation conv = Connect(remoteFileName);
            try
            {
                FileStream fs = File.OpenWrite(localFileName);
                try
                {
                    Receive(conv, fs);
                }
                finally
                {
                    fs.Close();
                }
            }
            finally
            {
                conv.Close();
            }
        }
        catch (IOException eIO)
        {
            Console.WriteLine("ERROR: " + eIO.Message);
            Environment.Exit(1);
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Beispiel #7
0
    public static void Main(string[] args)
    {
        if ((args.Length < 3) || (args.Length > 4))
        {
            Console.WriteLine("Usage: SimpleEnqueuer <qspace> <qname> <message> [<replyq>]");
            Environment.Exit(1);
        }

        string qSpace  = args[0];
        string qName   = args[1];
        string message = args[2];
        string replyQ  = (args.Length < 4) ? null : args[3];

        ATMI.tpinit(null);
        try
        {
            ByteBuffer data = StringUtils.NewStringBuffer(message);
            try
            {
                TPQCTL ctl = new TPQCTL();
                ctl.flags = ATMI.TPNOFLAGS;
                if (replyQ != null)
                {
                    ctl.flags      = ctl.flags | ATMI.TPQREPLYQ;
                    ctl.replyqueue = replyQ;
                }
                ATMI.tpenqueue(qSpace, qName, ctl, data, 0, 0);
                Console.WriteLine("Enqueued '" + message + "' in " + qSpace + "." + qName);
            }
            finally
            {
                ATMI.tpfree(data);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Beispiel #8
0
    public static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("Usage: SimpleFML32Client <field>=<value> ...");
            Environment.Exit(1);
        }

        ATMI.tpinit(null);
        try
        {
            ByteBuffer fbfr = ATMI.tpalloc("FML32", null, 512);
            try
            {
                foreach (string arg in args)
                {
                    int    eqPos = arg.IndexOf('=');
                    string key   = arg.Substring(0, eqPos);
                    string val   = arg.Substring(eqPos + 1);
                    int    fldid = FML32.Fldid(key);
                    TPFBuilder.I.FaddString(ref fbfr, fldid, val);
                }

                int len;
                ATMI.tpcall("FML32_TOUPPER", fbfr, 0, ref fbfr, out len, 0);

                Console.WriteLine("Returned FML32 buffer is: " + FML32.ToString(fbfr));
            }
            finally
            {
                ATMI.tpfree(fbfr);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }
Beispiel #9
0
    public static void Main(string[] args)
    {
        if ((args.Length < 1) || (args.Length > 2))
        {
            Console.WriteLine("Usage: SimpleSubscriber <eventexpr> [<filter>]");
            Environment.Exit(1);
        }

        string eventexpr = args[0];
        string filter    = (args.Length < 2) ? null : args[1];

        ATMI.tpinit(null);
        try
        {
            ATMI.tpsetunsol(new UnsolHandler(tpunsol));
            try
            {
                Console.WriteLine("Subscribing to events matching '" + eventexpr + "'");
                int handle = ATMI.tpsubscribe(eventexpr, filter, null, 0);
                try
                {
                    ProcessMessages(5);
                }
                finally
                {
                    ATMI.tpunsubscribe(handle, 0);
                }
            }
            finally
            {
                ATMI.tpsetunsol(null);
            }
        }
        finally
        {
            ATMI.tpterm();
        }
    }