Exemplo n.º 1
0
Arquivo: test.cs Projeto: demonxjj/TCE
        public override void callReturn(RpcMessage m1, RpcMessage m2)
        {
            bool         r      = false;
            MemoryStream d      = new MemoryStream(m2.paramstream);
            BinaryReader reader = new BinaryReader(d);

            if (m1.opidx == 0)
            {
                string b_5 = "";
                b_5 = RpcBinarySerializer.readString(reader);
                echo(b_5, m1.prx, m1.cookie);
            }
            if (m1.opidx == 1)
            {
                timeout(m1.prx, m1.cookie);
            }
            if (m1.opidx == 2)
            {
                heartbeat(m1.prx, m1.cookie);
            }
            if (m1.opidx == 3)
            {
                bidirection(m1.prx, m1.cookie);
            }
        }
Exemplo n.º 2
0
Arquivo: test.cs Projeto: demonxjj/TCE
        // timeout - msec ,  0 means waiting infinitely
        public string datetime(int timeout, Dictionary <string, string> props)
        {
            bool       r_1 = false;
            RpcMessage m_2 = new RpcMessage(RpcMessage.CALL);

            m_2.ifidx     = 0;
            m_2.opidx     = 0;
            m_2.paramsize = 0;
            m_2.extra.setProperties(props);
            try{
                m_2.prx = this;
            }catch (Exception e) {
                RpcCommunicator.instance().logger.error(e.ToString());
                throw new RpcException(RpcException.RPCERROR_DATADIRTY, e.ToString());
            }
            r_1 = this.conn.sendMessage(m_2);
            if (!r_1)
            {
                throw new RpcException(RpcException.RPCERROR_SENDFAILED);
            }
            bool _rc_3 = false;

            try{
                if (timeout > 0)
                {
                    _rc_3 = m_2.ev.WaitOne(timeout);
                }
                else
                {
                    _rc_3 = m_2.ev.WaitOne(RpcCommunicator.instance().getProperty_DefaultCallWaitTime());
                }
            }catch (Exception e) {
                RpcCommunicator.instance().logger.error(e.ToString());
                throw new RpcException(RpcException.RPCERROR_INTERNAL_EXCEPTION, e.ToString());
            }
            if (_rc_3 == false)
            {
                throw new RpcException(RpcException.RPCERROR_TIMEOUT);
            }
            if (m_2.errcode != RpcException.RPCERROR_SUCC)
            {
                throw new RpcException(m_2.errcode);
            }
            if (m_2.result == null)
            {
                throw new RpcException(RpcException.RPCERROR_TIMEOUT, "response is null");
            }
            string b_4 = "";

            try{
                RpcMessage   m2_5      = (RpcMessage)m_2.result;
                MemoryStream d_6       = new MemoryStream(m2_5.paramstream);
                BinaryReader _reader_7 = new BinaryReader(d_6);
                b_4 = RpcBinarySerializer.readString(_reader_7);
            }catch (Exception e) {
                RpcCommunicator.instance().logger.error(e.ToString());
                throw new RpcException(RpcException.RPCERROR_DATADIRTY);
            }
            return(b_4);    //regardless if  unmarshalling is okay
        }
Exemplo n.º 3
0
Arquivo: test.cs Projeto: demonxjj/TCE
        public override void callReturn(RpcMessage m1, RpcMessage m2)
        {
            bool         r      = false;
            MemoryStream d      = new MemoryStream(m2.paramstream);
            BinaryReader reader = new BinaryReader(d);

            if (m1.opidx == 0)
            {
                string b_10 = "";
                b_10 = RpcBinarySerializer.readString(reader);
                datetime(b_10, m1.prx, m1.cookie);
            }
        }
Exemplo n.º 4
0
Arquivo: test.cs Projeto: demonxjj/TCE
        // func: echo
        bool func_0_delegate(RpcMessage m)
        {
            bool         r      = false;
            MemoryStream bos    = new MemoryStream(m.paramstream);
            BinaryReader reader = new BinaryReader(bos);
            string       text;

            text = RpcBinarySerializer.readString(reader);
            Server     servant = (Server)this.inst;
            RpcContext ctx     = new RpcContext();

            ctx.msg = m;
            string cr;

            cr = servant.echo(text, ctx);
            if ((m.calltype & RpcMessage.ONEWAY) != 0)
            {
                return(true);
            }

            RpcMessage mr = new RpcMessage(RpcMessage.RETURN);

            mr.sequence = m.sequence;
            mr.callmsg  = m;
            mr.conn     = m.conn;
            mr.ifidx    = m.ifidx;
            mr.call_id  = m.call_id;
            if (m.extra.getProperties().ContainsKey("__user_id__"))
            {
                mr.extra.setPropertyValue("__user_id__", m.extra.getPropertyValue("__user_id__"));
            }
            try{
                MemoryStream _bos_9 = new MemoryStream();
                BinaryWriter dos    = new BinaryWriter(_bos_9);
                RpcBinarySerializer.writeString(cr, dos);
                mr.paramsize   = 1;
                mr.paramstream = _bos_9.ToArray();
            }catch (Exception e) {
                RpcCommunicator.instance().logger.error(e.ToString());
                r = false;
                return(r);
            }
            r = m.conn.sendMessage(mr);
            return(r);
        }
Exemplo n.º 5
0
Arquivo: test.cs Projeto: demonxjj/TCE
        // func: onMessage
        bool func_0_delegate(RpcMessage m)
        {
            bool         r      = false;
            MemoryStream bos    = new MemoryStream(m.paramstream);
            BinaryReader reader = new BinaryReader(bos);
            string       message;

            message = RpcBinarySerializer.readString(reader);
            ITerminal  servant = (ITerminal)this.inst;
            RpcContext ctx     = new RpcContext();

            ctx.msg = m;
            servant.onMessage(message, ctx);
            if ((m.calltype & RpcMessage.ONEWAY) != 0)
            {
                return(true);
            }

            return(r);
        }
Exemplo n.º 6
0
Arquivo: test.cs Projeto: demonxjj/TCE
        // func: heartbeat
        bool func_2_delegate(RpcMessage m)
        {
            bool         r      = false;
            MemoryStream bos    = new MemoryStream(m.paramstream);
            BinaryReader reader = new BinaryReader(bos);
            string       hello;

            hello = RpcBinarySerializer.readString(reader);
            Server     servant = (Server)this.inst;
            RpcContext ctx     = new RpcContext();

            ctx.msg = m;
            servant.heartbeat(hello, ctx);
            if ((m.calltype & RpcMessage.ONEWAY) != 0)
            {
                return(true);
            }

            return(r);
        }