示例#1
0
 public NewConnectionEventArgs(Platform.Connection connection) : base(NewConnectionEvent)
 {
     Connection = connection;
 }
示例#2
0
        private bool ApplyResponse(DataResponse response)
        {
            if (response.Version >= NetworkProtocol.NETWORK_PROTOCOL_MIN_VERSION)
            {
                //SaveTestResponse(response);

                switch (response.ResponseType)
                {
                case DataResponse.Type.ReportProgress:
                    Int32 length = response.Reader.ReadInt32();
                    StatusText.Text = new String(response.Reader.ReadChars(length));
                    break;

                case DataResponse.Type.NullFrame:
                    RaiseEvent(new CancelConnectionEventArgs());
                    StatusText.Visibility = System.Windows.Visibility.Collapsed;
                    lock (frames)
                    {
                        frames.Flush();
                        ScrollToEnd();
                    }
                    break;

                case DataResponse.Type.Handshake:
                    TracerStatus status = (TracerStatus)response.Reader.ReadUInt32();

                    KeyValuePair <string, string> warning;
                    if (statusToError.TryGetValue(status, out warning))
                    {
                        RaiseEvent(new ShowWarningEventArgs(warning.Key, warning.Value));
                    }

                    if (response.Version >= NetworkProtocol.NETWORK_PROTOCOL_VERSION_23)
                    {
                        Platform.Connection connection = new Platform.Connection()
                        {
                            Address = response.Source.Address.ToString(),
                            Port    = response.Source.Port
                        };
                        Platform.Type target     = Platform.Type.Unknown;
                        String        targetName = Utils.ReadBinaryString(response.Reader);
                        Enum.TryParse(targetName, true, out target);
                        connection.Target = target;
                        connection.Name   = Utils.ReadBinaryString(response.Reader);
                        RaiseEvent(new NewConnectionEventArgs(connection));
                    }

                    break;

                default:
                    lock (frames)
                    {
                        frames.Add(response);
                        //ScrollToEnd();
                    }
                    break;
                }
            }
            else
            {
                RaiseEvent(new ShowWarningEventArgs("Invalid NETWORK_PROTOCOL_VERSION", String.Empty));
                return(false);
            }
            return(true);
        }