示例#1
0
        public IStyxMessage GetMessage()
        {
            IStyxMessage res = null;
            switch (type)
            {
                case MessageType.Twalk:
                case MessageType.Rwalk:
                    res = new StyxWalkMessage();
                    break;
                case MessageType.Tversion:
                case MessageType.Rversion:
                    res = new StyxVersionMessage();
                    break;
                case MessageType.Tclunk:
                case MessageType.Rclunk:
                    res = new StyxClunkMessage();
                    break;
                case MessageType.Tstat:
                case MessageType.Rstat:
                    res = new StyxStatMessage();
                    break;
                case MessageType.Topen:
                case MessageType.Ropen:
                    res = new StyxOpenMessage();
                    break;
                case MessageType.Tread:
                case MessageType.Rread:
                    res = new StyxReadMessage();
                    break;
                case MessageType.Tattach:
                case MessageType.Rattach:
                    res = new StyxAttachMessage();
                    break;

            }
            if (res != null)
            {
                res.SetBinary(data);
            }
            return res;
        }
示例#2
0
        private IStyxMessage HandleWalk(StyxWalkMessage message)
        {
            if (!fid_list.ContainsKey(message.Fid))
            {
                throw new Exception("Unknown fid");
            }
            StyxFileSystemInterface fsitem = fid_list[message.Fid];

            StyxFileSystemInterface newitem;
            StyxMessage.QID[] qids;
            int res = fsitem.Walk(out newitem, out qids, message.PathComponents);
            if (res == 0)
            {
                // target found
                // we must register fid
                RegisterFID(message.NewFid, newitem);
            }
            return new StyxWalkMessage(message.Tag, qids);
        }