Пример #1
0
        public bool SeekToFirst(UInt64 itid)
        {
            NetMessage netMessage = Protocol_IteratorSeekToFirst.CreateSendMsg(itid);

            actor.Tell(netMessage.ToBytes());
            return(ItID_STF.Get(itid).Result);
        }
Пример #2
0
        public override void OnTell(IModulePipeline from, byte[] data)
        {
            if (from == null)//来自自己
            {
                var actor = this.GetPipeline(string.Format("{0}:{1}/{2}", setting.DBServerAddress, setting.DBServerPort, setting.DBServerPath));
                actor.Tell(data);
            }

            if (from != null && from.system.Remote != null)//来自server
            {
                using (MemoryStream ms = new MemoryStream(data))
                {
                    NetMessage netMsg = NetMessage.Unpack(ms);
                    if (netMsg.Cmd == "_db.usesnapshot")
                    {
                        UInt64 sid = Protocol_UseSnapShot.PraseRecvMsg(netMsg);
                        Utc_SID.Add(netMsg.ID, sid);
                    }
                    if (netMsg.Cmd == "_db.getvalue")
                    {
                        byte[] value = Protocol_GetValue.PraseRecvMsg(netMsg);
                        var    str   = netMsg.Param.key == null?netMsg.Param.tableid.ToHexString() : netMsg.Param.tableid.Concat(netMsg.Param.key).ToArray().ToHexString();

                        K_V.Add(str, value);
                    }
                    if (netMsg.Cmd == "_db.snapshot.newiterator")
                    {
                        UInt64 itid = Protocol_CreateIterator.PraseRecvMsg(netMsg);
                        SID_ItId.Add(netMsg.Param.snapid, itid);
                    }
                    if (netMsg.Cmd == "_db.iterator.current")
                    {
                        byte[] value = Protocol_IteratorCurrent.PraseRecvMsg(netMsg);
                        ItID_Cur.Add(netMsg.Param.itid, value);
                    }
                    if (netMsg.Cmd == "_db.iterator.next")
                    {
                        bool result = Protocol_IteratorNext.PraseRecvMsg(netMsg);
                        ItID_Next.Add(netMsg.Param.itid, result);
                    }
                    if (netMsg.Cmd == "_db.iterator.seektofirst")
                    {
                        bool result = Protocol_IteratorSeekToFirst.PraseRecvMsg(netMsg);
                        ItID_STF.Add(netMsg.Param.itid, result);
                    }
                }
            }
        }