Пример #1
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();
        }
    }
Пример #2
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();
        }
    }
Пример #3
0
    public static void PUBLISH_TIME(TPSVCINFO svcinfo)
    {
        ByteBuffer message = StringUtils.NewStringBuffer("It is now " + DateTime.Now);

        try
        {
            ATMI.tppost("TIME", message, 0, 0);
        }
        catch (TPENOENT)
        {
            // EventBroker not running yet (ignored)
        }
        finally
        {
            ATMI.tpfree(message);
        }

        Thread.Sleep(1000);

        ATMI.tpacall("PUBLISH_TIME", null, 0, ATMI.TPNOREPLY);

        ATMI.tpreturn(ATMI.TPSUCCESS, 0, null, 0, 0);
    }
Пример #4
0
 public static int tpsvrinit(string[] args)
 {
     ATMI.tpacall("PUBLISH_TIME", null, 0, ATMI.TPNOREPLY);
     return(0);
 }