示例#1
0
 public ClientSession(Socket socket, MonoDebugServer server)
 {
     Server = server;
     if (socket != null)
     {
         remoteEndpoint = ((IPEndPoint)socket.RemoteEndPoint).Address;
     }
     RootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "MonoToolsServer");
     if (remoteEndpoint != null)
     {
         RootPath = Path.Combine(RootPath, remoteEndpoint.ToString());
     }
     communication          = new TcpCommunication(socket, CanCompress, Roles.Server, IsLocal, Password, RootPath);
     communication.Progress = progress => {
         const int Width = 60;
         Console.CursorLeft = 0;
         var n         = (int)(Width * progress + 0.5);
         var p         = ((int)(progress * 100 + 0.5)).ToString() + "%";
         var t         = (Width - p.Length) / 2;
         var backColor = Console.BackgroundColor;
         for (int i = 0; i < Width; i++)
         {
             Console.BackgroundColor = i < n ? ConsoleColor.DarkGreen : ConsoleColor.DarkGray;
             Console.Write((i < t || i >= t + p.Length) ? ' ' : p[i - t]);
         }
         Console.BackgroundColor = backColor;
     };
 }
示例#2
0
 public static MonoProcess Start(ExecuteMessage msg, MonoDebugServer server, ClientSession session)
 {
     if (msg.ApplicationType == ApplicationTypes.WebApplication)
     {
         return(new MonoWebProcess(msg, server, session));
     }
     return(new MonoDesktopProcess(msg, server, session));
 }
示例#3
0
        public virtual Message Receive()
        {
            lock (this) if (buffer.Count > 0)
                {
                    return(buffer.Pop());
                }
            if (IsLocal)
            {
                if (Role == Roles.Client)
                {
                    return(client.Dequeue());
                }
                else
                {
                    return(server.Dequeue());
                }
            }
            var len = reader.ReadInt32();
            var buf = new byte[len];

            //while (socket.Available <= 0) System.Threading.Thread.Sleep(10);
            reader.Read(buf, 0, len);
            var m   = new MemoryStream(buf);
            var msg = (Message)serializer.Deserialize(m);

            if (msg == null)
            {
                throw new InvalidOperationException("Message must not be null.");
            }
            if (!msg.CheckSecurityToken(this))
            {
                SendAsync(new StatusMessage(Commands.InvalidPassword));
                MonoDebugServer.InvalidPassword();
            }
            if (msg is IExtendedMessage)
            {
                ((IExtendedMessage)msg).Receive(this);
            }
            return(msg);
        }
示例#4
0
 public MonoProcess(ExecuteMessage msg, MonoDebugServer server, ClientSession session)
 {
     Message = msg; Server = server; Session = session; Cancel = new CancellationTokenSource();
 }
示例#5
0
 public MonoDesktopProcess(ExecuteMessage msg, MonoDebugServer server, ClientSession session) : base(msg, server, session)
 {
     RedirectOutput = msg.ApplicationType == ApplicationTypes.WindowsApplication;
 }
示例#6
0
 public MonoWebProcess(ExecuteMessage msg, MonoDebugServer server, ClientSession session) : base(msg, server, session)
 {
     RedirectOutput = true;
 }