Beispiel #1
0
        public void heartbeat_async(string hello, Server_AsyncCallBack async, Dictionary <string, string> props, object cookie)
        {
            bool       r_5 = false;
            RpcMessage m_6 = new RpcMessage(RpcMessage.CALL | RpcMessage.ASYNC);

            m_6.ifidx     = 2;
            m_6.opidx     = 2;
            m_6.paramsize = 1;
            m_6.extra.setProperties(props);
            m_6.cookie = cookie;
            try{
                MemoryStream bos_7 = new MemoryStream();
                BinaryWriter dos_8 = new BinaryWriter(bos_7);
                RpcBinarySerializer.writeString(hello, dos_8);
                m_6.paramstream = bos_7.ToArray();
                m_6.prx         = this;
                m_6.async       = async;
            }catch (Exception e) {
                throw new RpcException(RpcException.RPCERROR_DATADIRTY, e.ToString());
            }
            r_5 = this.conn.sendMessage(m_6);
            if (!r_5)
            {
                throw new RpcException(RpcException.RPCERROR_SENDFAILED);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        public void echo_async(string text, Server_AsyncCallBack async, Dictionary <string, string> props, object cookie)
        {
            bool       r_10 = false;
            RpcMessage m_11 = new RpcMessage(RpcMessage.CALL | RpcMessage.ASYNC);

            m_11.ifidx     = 2;
            m_11.opidx     = 0;
            m_11.paramsize = 1;
            m_11.extra.setProperties(props);
            m_11.cookie = cookie;
            try{
                MemoryStream bos_12 = new MemoryStream();
                BinaryWriter dos_13 = new BinaryWriter(bos_12);
                RpcBinarySerializer.writeString(text, dos_13);
                m_11.paramstream = bos_12.ToArray();
                m_11.prx         = this;
                m_11.async       = async;
            }catch (Exception e) {
                throw new RpcException(RpcException.RPCERROR_DATADIRTY, e.ToString());
            }
            r_10 = this.conn.sendMessage(m_11);
            if (!r_10)
            {
                throw new RpcException(RpcException.RPCERROR_SENDFAILED);
            }
        }
Beispiel #4
0
        // 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
        }
Beispiel #5
0
        // timeout - msec ,  0 means waiting infinitely
        public void heartbeat(string hello, int timeout, Dictionary <string, string> props)
        {
            bool       r_1 = false;
            RpcMessage m_2 = new RpcMessage(RpcMessage.CALL);

            m_2.ifidx     = 2;
            m_2.opidx     = 2;
            m_2.paramsize = 1;
            m_2.extra.setProperties(props);
            try{
                MemoryStream bos_3 = new MemoryStream();
                BinaryWriter dos_4 = new BinaryWriter(bos_3);
                RpcBinarySerializer.writeString(hello, dos_4);
                m_2.paramstream = bos_3.ToArray();
                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_5 = false;

            try{
                if (timeout > 0)
                {
                    _rc_5 = m_2.ev.WaitOne(timeout);
                }
                else
                {
                    _rc_5 = 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_5 == 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");
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        // 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);
        }
Beispiel #8
0
        // 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);
        }
Beispiel #9
0
        // 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);
        }
Beispiel #10
0
        // func: timeout
        bool func_1_delegate(RpcMessage m)
        {
            bool         r      = false;
            MemoryStream bos    = new MemoryStream(m.paramstream);
            BinaryReader reader = new BinaryReader(bos);
            int          secs;

            secs = RpcBinarySerializer.readInt(reader);
            Server     servant = (Server)this.inst;
            RpcContext ctx     = new RpcContext();

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

            return(r);
        }
Beispiel #11
0
        public void heartbeat_oneway(string hello, Dictionary <string, string> props)
        {
            bool       r_1 = false;
            RpcMessage m_2 = new RpcMessage(RpcMessage.CALL | RpcMessage.ONEWAY);

            m_2.ifidx     = 2;
            m_2.opidx     = 2;
            m_2.paramsize = 1;
            m_2.extra.setProperties(props);
            try{
                MemoryStream bos_3 = new MemoryStream();
                BinaryWriter dos_4 = new BinaryWriter(bos_3);
                RpcBinarySerializer.writeString(hello, dos_4);
                m_2.paramstream = bos_3.ToArray();
                m_2.prx         = this;
            }catch (Exception e) {
                throw new RpcException(RpcException.RPCERROR_DATADIRTY, e.ToString());
            }
            r_1 = this.conn.sendMessage(m_2);
            if (!r_1)
            {
                throw new RpcException(RpcException.RPCERROR_SENDFAILED);
            }
        }