Exemplo n.º 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;
        }
Exemplo n.º 2
0
 private IStyxMessage HandleOpen(StyxOpenMessage message)
 {
     if (!fid_list.ContainsKey(message.Fid))
     {
         throw new Exception("Unknown fid");
     }
     StyxFileSystemInterface fsitem = fid_list[message.Fid];
     StyxMessage.QID qid;
     int res = fsitem.Open(message.Mode, out qid);
     if (res != 0)
     {
         throw new Exception("Open failed("+res+")");
     }
     // max buffer size = iobuf - TWrite extra info size (23 bytes)
     return new StyxOpenMessage(message.Tag, qid, iobuf_size - 23 );
 }