Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ExecuteTest)
     {
         string genBytesUrl = ResolveClientUrl(CallBackUrl);
         string script      = AstMainScript.Text
                              .Replace("{$GEN_BYTES_URL$}", genBytesUrl)
                              .Replace("{$BYTE_LENGTH$}", ByteLength.ToString())
                              .Replace("{$COMPLETE_FUNCTION$}", ClientCompleteFunction)
                              .Replace("{$USE_COOKIE$}", UseCookie.ToString().ToLower())
                              .Replace("{$COOKIE_EXPIRES$}", CookieExpires.TotalDays.ToString());
         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "AjaxSpeedTest",
                                                     script);
     }
 }
Exemplo n.º 2
0
        public UdpSession(UdpServer Server, Socket ServerSocket, IPEndPoint RemoteEndPoint, Func <ISessionContext, IBinaryTransformer, KeyValuePair <IServerImplementation, IStreamedVirtualTransportServer> > VirtualTransportServerFactory, Action <Action> QueueUserWorkItem)
        {
            this.Server              = Server;
            this.ServerSocket        = ServerSocket;
            this.RemoteEndPoint      = RemoteEndPoint;
            this.LastActiveTimeValue = new LockedVariable <DateTime>(DateTime.UtcNow);
            ssm = new SessionStateMachine <StreamedVirtualTransportServerHandleResult, Unit>(ex => ex is SocketException, OnCriticalError, OnShutdownRead, OnShutdownWrite, OnWrite, OnExecute, OnStartRawRead, OnExit, QueueUserWorkItem);

            Context                = Server.ServerContext.CreateSessionContext();
            Context.Quit          += ssm.NotifyExit;
            Context.Authenticated += () => Server.NotifySessionAuthenticated(this);

            var rpst = new Rc4PacketServerTransformer();
            var Pair = VirtualTransportServerFactory(Context, rpst);

            si  = Pair.Key;
            vts = Pair.Value;
            Context.SecureConnectionRequired += c =>
            {
                rpst.SetSecureContext(c);
                NextSecureContext = c;
            };
            vts.ServerEvent           += () => ssm.NotifyWrite(new Unit());
            vts.InputByteLengthReport += (CommandName, ByteLength) => Server.ServerContext.RaiseSessionLog(new SessionLogEntry {
                Token = Context.SessionTokenString, RemoteEndPoint = RemoteEndPoint, Time = DateTime.UtcNow, Type = "InBytes", Name = CommandName, Message = ByteLength.ToInvariantString()
            });
            vts.OutputByteLengthReport += (CommandName, ByteLength) => Server.ServerContext.RaiseSessionLog(new SessionLogEntry {
                Token = Context.SessionTokenString, RemoteEndPoint = RemoteEndPoint, Time = DateTime.UtcNow, Type = "OutBytes", Name = CommandName, Message = ByteLength.ToInvariantString()
            });
        }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     return((EncryptedHash?.GetHashCode().ToString() + RelativeFilePath.ToString() + ByteLength.ToString()).GetHashCode());
 }
Exemplo n.º 4
0
        public override string ToDebugString(Frame fmsg)
        {
            var    msg = (N2kFrame)fmsg;
            string s   = ((N2kHeader)msg.Header).PGN.ToString() + ": " + (Name ?? "") + "\nSource=" + msg.Header.PGNSource + "\nDestination=" + msg.Header.PGNDestination + "\nPriority=" + msg.Header.PGNPriority + "\nExpected Length=" + ByteLength.ToString() + " bytes" + "\nActual Length=" + msg.Data.Length + " bytes\n";

            // string s = ((N2kHeader)msg.Header).PGN.ToString() + ": " + (Name ?? "") + ", Source=" + msg.Header.PGNSource + ", Destination=" + msg.Header.PGNDestination + ", Priority=" + msg.Header.PGNPriority + ", Length=" + ByteLength.ToString() + " bytes\n";
            if ((msg.Defn == null) || (msg.Defn is PGNDefnUnknown))
            {
                // We output each byte with its binary representation
                for (int i = 0; i < msg.Data.Length; i++)
                {
                    s = s + Tools.Dump(msg.Data, 8 * i, 8);
                    s = s + "  " + "Byte " + i.ToString() + "\n";
                }
            }
            else
            {
                foreach (N2kField f in Fields)
                {
                    var BitOffset = f.BitOffset;
                    // We ignore fields that have not been transmitted, eg see PGN 127250
                    if (f.BitOffset + f.BitLength <= (msg.Data.Length) << 3)
                    {
                        s = s + f.DebugString(msg.Data);
                        s = s + "  " + f.Name + "=" + f.ToString(msg.Data) + "\n"; //  +"{" + (f as Field).ToString(msg.Data) + "}" + "\n";
                    }
                }
            }
            return(s);
        }
Exemplo n.º 5
0
        public override string ToString(Frame fmsg)
        {
            var    msg = (N2kFrame)fmsg;
            string s   = ((N2kHeader)msg.Header).PGN.ToString() + ": " + (Name ?? "") + "\nSource=" + msg.Header.PGNSource + "\nDestination=" + msg.Header.PGNDestination + "\nPriority=" + msg.Header.PGNPriority + "\nExpected Length=" + ByteLength.ToString() + " bytes" + "\nActual Length=" + msg.Data.Length + " bytes\n";

            foreach (N2kField f in Fields)
            {
                // We ignore fields that have not been transmitted, eg see PGN 127250
                if (f.BitOffset + f.BitLength <= (msg.Data.Length) << 3)
                {
                    s = s + "  " + f.Name + "=" + f.ToString(msg.Data) + "\n"; //  +"{" + (f as Field).ToString(msg.Data) + "}" + "\n";
                }
            }
            return(s);
        }
Exemplo n.º 6
0
 public override int GetHashCode() => (EncryptedHash.GetHashCode().ToString() + RelativeFilePath.ToString() + ByteLength.ToString()).GetHashCode();
Exemplo n.º 7
0
 public override int GetHashCode()
 {
     return(ByteLength.GetHashCode());
 }