Exemple #1
0
        private void SendBackToReg(Message message, Express.IServer server, Express.ChannelReceiveEventArgs e, IProtocolBuffer protocolbuffer, int typeToBack = 0)
        {
            e.Channel.Tag = protocolbuffer;
            var result = GetTyepToBack(message, typeToBack);

            Express.Data data = new Express.Data(result.Array, result.Length);
            data.Tag = result;
            server.Send(data, e.Channel);
        }
Exemple #2
0
        public void Receive(Express.IServer server, Express.ChannelReceiveEventArgs e)
        {
            IProtocolBuffer protocolbuffer;

            if (e.Channel.Tag == null)
            {
                protocolbuffer = ProtocolBufferPool.Default.Pop();
                e.Channel.Tag  = protocolbuffer;
            }
            else
            {
                protocolbuffer = (IProtocolBuffer)e.Channel.Tag;
            }
            int offset = 0; int count = e.Data.Count;

            while (count > 0)
            {
                int readcout = protocolbuffer.Import(e.Data.Array, 0, count);
                if (readcout > 0)
                {
                    Message message = MessageFactory.MessageFromBuffer(protocolbuffer);
                    ProtocolBufferPool.Default.Push(protocolbuffer);
                    protocolbuffer = ProtocolBufferPool.Default.Pop();
                    e.Channel.Tag  = protocolbuffer;
                    IProtocolBuffer result = MessageFactory.MessateToBuffer <CenterResponse>(
                        message.BussinessNO, message.SIM, (m, b) =>
                    {
                        b.BussinessNO = message.BussinessNO;
                        b.ResultID    = message.ID;
                        b.Result      = ResultType.Success;
                    });
                    Beetle.Express.Data data = new Express.Data(result.Array, result.Length);
                    data.Tag = result;
                    server.Send(data, e.Channel);
                    offset += readcout;
                    count  -= readcout;
                }
            }
        }