Пример #1
0
        public void OnMsg(ReliableTransferMsg msg)
        {
            if (netFail)
            {
                return;
            }

            StreamTransferSession session;
            ArgCollection         args;
            AppRef         appRef;
            AppPackageInfo packageInfo;
            string         path;

            args   = ArgCollection.Parse(msg.Args);
            appRef = AppRef.Parse(args["appref"]);

            if (msg.Direction == TransferDirection.Upload)
            {
                path    = packageFolder.BeginTransit(appRef);
                session = StreamTransferSession.ServerUpload(router, msg, path);
                session.BeginTransfer(onTransfer, new TransferInfo(session, path, msg.Direction));
            }
            else
            {
                packageInfo = packageFolder.GetPackageInfo(appRef);
                if (packageInfo == null)
                {
                    throw SessionException.Create(null, "Package [{0}] cannot be found.", appRef);
                }

                path    = packageInfo.FullPath;
                session = StreamTransferSession.ServerDownload(router, msg, path);
                session.BeginTransfer(onTransfer, new TransferInfo(session, path, msg.Direction));
            }
        }
Пример #2
0
        public void OnMsgUpload(ReliableTransferMsg msg)
        {
            StreamTransferSession session;

            session = StreamTransferSession.ServerUpload(msg._Session.Router, msg, msServer = new EnhancedMemoryStream());
            session.SimulateCancel = simServerCancel;
            session.SimulateError  = simServerError;
            session.BeginTransfer(new AsyncCallback(OnServerDone), session);
            serverArgs = msg.Args;
        }