Ejemplo n.º 1
0
        /// <summary>
        /// Test connect click event procedure.
        /// </summary>
        private void Button_Connect_Click(object sender, EventArgs e)
        {
            // set result to default value ..
            resultVar = ConnectResult.NONE;

            // lock controls ..
            this.FormControls(false);

            // analysis server address ..
            IPAddress[] ipadds = Dns.GetHostAddresses(this.TextBox_Server.Text.Trim());
            if (ipadds.Length > 0)
            {
                // assign ip address ..
                this.Addr = ipadds[0];

                // create therad object ..
                __Connect = new System.Threading.Thread(
                    new System.Threading.ParameterizedThreadStart(this.Connecting));

                // start thread process and timer check ..
                __Connect.Start(ipadds[0]);
                __reply.Start();
            }
            else
            {
                MessageBox.Show(this.ParseErrMsg, AssemblyInfoClass.ProductInfo,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                // unlock controls ..
                this.FormControls(true);

                return;
            }
        }
Ejemplo n.º 2
0
        public static string BuildChannelError(IClientInputChannel channel, ConnectResult result, bool isException)
        {
            var messageBuilder = new StringBuilder();

            messageBuilder.AppendFormat("Unable to connect ");

            if (isException)
            {
                messageBuilder.AppendFormat(" due to an application error");
            }
            else
            {
                switch (result)
                {
                case ConnectResult.AuthFailure:
                    messageBuilder.AppendFormat(", server said: {0}", channel.AuthMessage);
                    break;

                default:
                    messageBuilder.AppendFormat(" due to a channel error");
                    break;
                }
            }

            return(messageBuilder.ToString());
        }
        public async Task connect_with_clean_session_but_connack_return_code_is_invalid_should_throw()
        {
            Queue <TestPacket> packets        = new();
            TestPacket         connectPacket  = TestPacket.Outgoing("101600044d5154540402001e000a434b4d71747454657374");
            const int          startSkipCount = 6;     // These packets are valid, so we skip them.

            for (byte i = startSkipCount; i != 0; i++) //Ok there we loop over all non zero bytes.
            {
                packets.Enqueue(connectPacket);
                packets.Enqueue(TestPacket.Incoming("200200" + BitConverter.ToString(new byte[] { i })));
            }

            PacketReplayer packetReplayer = new(packets);

            IMqtt3Client client = MqttClient.Factory.CreateMQTT3Client(TestConfigs.DefaultTestConfig(packetReplayer), (IActivityMonitor m, DisposableApplicationMessage msg) =>
            {
                msg.Dispose();
                return(new ValueTask());
            });

            for (byte i = startSkipCount; i != 0; i++)
            {
                ConnectResult res = await client.ConnectAsync(TestHelper.Monitor, new MqttClientCredentials( "CKMqttTest", true ));

                res.ConnectError.Should().Be(ConnectError.ProtocolError_UnknownReturnCode);
            }
            packetReplayer.LastWorkTask !.IsCompletedSuccessfully.Should().BeTrue();
        }
Ejemplo n.º 4
0
        void desktopConnector1_ConnectEnded(ConnectResult res)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new CbGeneric <ConnectResult>(this.desktopConnector1_ConnectEnded), res);
            }
            else
            {
                this.Cursor = Cursors.Default;
                if (res == ConnectResult.Succeed)
                {
                    this.desktopConnector1.Visible    = true;
                    this.skinComboBox_quality.Visible = true;
                    this.skinLabel_quality.Visible    = true;

                    int quality = this.desktopConnector1.GetVideoQuality();
                    int index   = (quality - 1) / 5;
                    if (index < 0)
                    {
                        index = 0;
                    }
                    if (index > 3)
                    {
                        index = 3;
                    }
                    this.skinComboBox_quality.SelectedIndex = index;

                    return;
                }

                MessageBoxEx.Show(string.Format("连接{0}的桌面失败。原因:{1}", this.ownerName, res));
                this.Close();
            }
        }
        public async Task <ConnectResult> SendAccountAuthentication(ConnectData connectData)
        {
            var response = new SocketMessage();

            if (_socketManager.IsReconnecting)
            {
                response = await SendStandardMessage(
                    RouteProvider.AUTHENTICATION_RECONNECT,
                    RouteProvider.AuthenticationReconnect(connectData, _socketManager.ActiveCharacterId));
            }
            else
            {
                response = await SendStandardMessage(RouteProvider.LOGIN, RouteProvider.Login(connectData));
            }

            var loginData = SocketUtilities.ParseDataFromResponse <LoginDataDTO>(response.Response);

            ConnectResult connectResult = _socketManager.GetConnectResult();

            connectResult.IsConnected  = true;
            connectResult.AccessToken  = loginData?.AccessToken;
            connectResult.TW2AccountId = loginData?.PlayerId;

            _socketManager.ConnectData.AccessToken = loginData?.AccessToken;

            DataEvents.InvokeLoginDataAvailable(loginData);
            DataEvents.InvokeConnectionResult(connectResult);

            return(connectResult);
        }
Ejemplo n.º 6
0
 void camera_ConnectEnded(ConnectResult obj)
 {
     if (this.ConnectEnded != null)
     {
         this.ConnectEnded(obj);
     }
 }
Ejemplo n.º 7
0
 public ConnectEvent(EventInformation eventInformation, uint socket, EndPoint remoteEP, ConnectResult result)
     : base(eventInformation)
 {
     m_socket         = socket;
     m_remoteEndPoint = remoteEP;
     m_result         = result;
 }
        public static async void StartConnectionAndTestConnectionDuration()
        {
            //Arrange
            SocketManager socketManager = MockData.GetSocketManager();

            Account     account          = SecretData.GetValidTestAccount();
            ConnectData validCredentials = new ConnectData
            {
                Username          = account.Username,
                Password          = account.Password,
                ServerCountryCode = "en",
                WorldID           = "en48"
            };


            //Act
            ConnectResult result1 = await socketManager.StartConnection(validCredentials);

            Thread.Sleep(6000);

            SocketMessage message = RouteProvider.GetDefaultSendMessage(RouteProvider.SYSTEM_GETTIME);

            var result = await socketManager.Emit(message);

            Thread.Sleep(600000);

            //Assert
            Assert.True(socketManager.IsConnected);
            await socketManager.StopConnection(true);
        }
Ejemplo n.º 9
0
        public async Task <ConnectResult> Connect(string strDeviceID, NukiConnectionConfig connectionInfo)
        {
            ConnectResult result = ConnectResult.Failed;

            try
            {
                if (connectionInfo != null)
                {
                    m_connectionInfo = connectionInfo;
                }
                var deviceService = await GattDeviceService.FromIdAsync(strDeviceID);

                if (deviceService != null)
                {
                    foreach (var character in
                             deviceService.GetCharacteristics(KeyTurnerUGDIO.Value).
                             Concat(deviceService.GetCharacteristics(KeyTurnerPairingGDIO.Value)))
                    {
                        if (character.Uuid == KeyTurnerPairingGDIO.Value)
                        {
                            result = ConnectResult.Successfull;
                            m_pairingGDIO.SetConnection(character);
                        }
                        else if (character.Uuid == KeyTurnerUGDIO.Value)
                        {
                            result = ConnectResult.Successfull;
                            m_UGDIO.SetConnection(character);
                        }
                    }
                    if (m_bleDevice != null)
                    {
                        m_bleDevice.ConnectionStatusChanged -= M_bleDevice_ConnectionStatusChanged;
                    }
                    m_bleDevice = deviceService.Device;
                    m_bleDevice.ConnectionStatusChanged += M_bleDevice_ConnectionStatusChanged;
                    RaisePropertyChanged(nameof(Connected));
                }
                else
                {
                    Log.Warn($"Unable to get GattDeviceService.FromIdAsync(\"{strDeviceID}\");");
                }

                if (m_bleDevice?.ConnectionStatus == BluetoothConnectionStatus.Connected)
                {
                    result = ConnectResult.Connected;
                }
            }
            catch (Exception ex)
            {
                Log.Error("Connect failed: {0}", ex);
                if (ex is InvalidOperationException && (uint)ex.HResult == 0x8000000E)
                {
                    result = ConnectResult.NeedRepair;
                }
                else
                {
                }
            }
            return(result);
        }
Ejemplo n.º 10
0
 public ConnectEvent(EventInformation eventInformation, uint socket, EndPoint remoteEP, ConnectResult result)
     : base(eventInformation)
 {
     m_socket = socket;
     m_remoteEndPoint = remoteEP;
     m_result = result;
 }
Ejemplo n.º 11
0
        void desktopConnector1_ConnectEnded(ConnectResult res)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new CbGeneric<ConnectResult>(this.desktopConnector1_ConnectEnded), res);
            }
            else
            {
                this.Cursor = Cursors.Default;
                if (res == ConnectResult.Succeed)
                {
                    this.desktopConnector1.Visible = true;
                    this.skinComboBox_quality.Visible = true;
                    this.skinLabel_quality.Visible = true;

                    int quality = this.desktopConnector1.GetVideoQuality();
                    int index = (quality - 1) / 5;
                    if (index < 0)
                    {
                        index = 0;
                    }
                    if (index > 3)
                    {
                        index = 3;
                    }
                    this.skinComboBox_quality.SelectedIndex = index;

                    return;
                }

                MessageBoxEx.Show(string.Format("连接{0}的桌面失败。原因:{1}", this.ownerName, res));
                this.Close();
            }
        }
 void whiteBoard_ConnectEnded(ConnectResult obj)
 {
     if (this.ConnectEnded != null)
     {
         this.ConnectEnded(obj);
     }
 }
Ejemplo n.º 13
0
        public async Task connect_with_clean_session_but_connack_session_present_is_not_zero_should_fail()
        {
            Queue <TestPacket> packets       = new();
            TestPacket         connectPacket = TestPacket.Outgoing("101600044d5154540402001e000a434b4d71747454657374");

            for (byte i = 1; i != 0; i++)  //Ok there we loop over all non zero bytes.
            {
                packets.Enqueue(connectPacket);
                packets.Enqueue(TestPacket.Incoming("2002" + BitConverter.ToString(new byte[] { i }) + "00"));
            }

            PacketReplayer pcktReplayer = new(packets);

            IMqtt3Client client = MqttClient.Factory.CreateMQTT3Client(TestConfigs.DefaultTestConfig(pcktReplayer), (IActivityMonitor m, DisposableApplicationMessage msg) =>
            {
                msg.Dispose();
                return(new ValueTask());
            });
            ConnectResult res = await client.ConnectAsync(TestHelper.Monitor, new MqttClientCredentials( "CKMqttTest", true ));

            res.ConnectError.Should().Be(ConnectError.ProtocolError_SessionNotFlushed);
            for (byte i = 2; i != 0; i++)
            {
                res = await client.ConnectAsync(TestHelper.Monitor, new MqttClientCredentials( "CKMqttTest", true ));

                res.ConnectError.Should().Be(ConnectError.ProtocolError_InvalidConnackState);
            }
            pcktReplayer.LastWorkTask !.IsCompletedSuccessfully.Should().BeTrue();
        }
Ejemplo n.º 14
0
        internal static string BuildChannelError(IClientInputChannel channel, ConnectResult result, bool isException)
        {
            var messageBuilder = new StringBuilder();

            messageBuilder.Append(Strings.UnableToConnect);
            messageBuilder.Append(", ");

            if (isException)
            {
                messageBuilder.Append(Strings.DueToAnApplicationError);
            }
            else
            {
                switch (result)
                {
                    case ConnectResult.AuthFailure:
                        messageBuilder.AppendFormat(Strings.ServerSaid, channel.AuthMessage);
                        break;
                    default:
                        messageBuilder.Append(Strings.DueToAChannelError);
                        break;
                }
            }

            return messageBuilder.ToString();
        }
Ejemplo n.º 15
0
        public static string BuildChannelError(IClientInputChannel channel, ConnectResult result, bool isException)
        {
            var messageBuilder = new StringBuilder();

            messageBuilder.AppendFormat("Unable to connect ");

            if (isException)
            {
                messageBuilder.AppendFormat(" due to an application error");
            }
            else
            {
                switch (result)
                {
                    case ConnectResult.AuthFailure:
                        messageBuilder.AppendFormat(", server said: {0}", channel.AuthMessage);
                        break;
                    default:
                        messageBuilder.AppendFormat(" due to a channel error");
                        break;
                }
            }

            return messageBuilder.ToString();
        }
Ejemplo n.º 16
0
        public ConnectResult Connect()
        {
            _socket.SendHttpRequest("POST", "/vpnsvc/connect.cgi", Encoding.ASCII.GetBytes("VPNCONNECT"),
                                    SoftEtherNetwork.GetDefaultHeaders());

            var connectResponse = _socket.GetHttpResponse();

            if (connectResponse.code != 200)
            {
                return new ConnectResult {
                           Error = SoftEtherError.ConnectFailed
                }
            }
            ;

            var connectDict   = SoftEtherProtocol.Deserialize(connectResponse.body);
            var connectResult = ConnectResult.Deserialize(connectDict);

            if (connectResult.Valid())
            {
                RandomFromServer = connectResult.random;
            }

            return(connectResult);
        }
Ejemplo n.º 17
0
        public async Task <ConnectResult> IsServerAvailable()
        {
            var uriBuilder = new UriBuilder(Endpoint.Uri);

            uriBuilder.Path  += "/";
            uriBuilder.Scheme = uriBuilder.Scheme.Replace("ws", "http"); // FIXME: replacing "ws" with "http" is too hacky!

            var req = new UnityWebRequest();

            req.method = "GET";
            var url = uriBuilder.Uri.ToString().Replace("2567", "2568");

            req.url = url;

            req.SetRequestHeader("Accept", "application/json");

            req.downloadHandler = new DownloadHandlerBuffer();
            await req.SendWebRequest();

            var           json = req.downloadHandler.text;
            ConnectResult response;

            if (string.IsNullOrEmpty(json))
            {
                response        = new ConnectResult();
                response.result = false;
            }
            else
            {
                response = JsonUtility.FromJson <ConnectResult>(json);
            }
            return(response);
        }
Ejemplo n.º 18
0
        void UpdateLastValidationMemoWithOfflineError(ConnectResult result)
        {
            Dispatcher.Invoke(() =>
            {
                switch (result)
                {
                case ConnectResult.Success:

                    break;

                case ConnectResult.ConnectFailed:
                case ConnectResult.LoginFailed:
                    var uniqueId = UniqueID;
                    var memo     = new DesignValidationMemo
                    {
                        InstanceID = uniqueId,
                        IsValid    = false,
                    };
                    memo.Errors.Add(new ErrorInfo
                    {
                        InstanceID = uniqueId,
                        ErrorType  = ErrorType.Warning,
                        FixType    = FixType.None,
                        Message    = result == ConnectResult.ConnectFailed
                                          ? "Server is offline. This service will only execute when the server is online."
                                          : "Server login failed. This service will only execute when the login permissions issues have been resolved."
                    });
                    UpdateLastValidationMemo(memo);
                    break;
                }
            });
        }
        /// <summary>
        /// Will attempt to login with the account provided, if in test-mode then the connection will be closed immediately after.
        /// </summary>
        /// <param name="account">The account with which to login</param>
        /// <param name="testMode">Will close the connection immediately after if true</param>
        /// <returns>The connection result</returns>
        public async Task <ConnectResult> LoginWithAccount(Account account, bool testMode = false)
        {
            // Make sure to reset the connection and deleting it.
            await _socketManager.StopConnection(true);

            ConnectResult result = await _socketManager.StartConnection(account.ToConnectData());

            if (!result.IsConnected)
            {
                return(result);
            }

            result = await SendAccountAuthentication(account.ToConnectData());

            await SendSystemIdentify();

            result.IsConnected = await SendCharacterSelect(account.DefaultCharacter);

            if (testMode)
            {
                await _socketManager.StopConnection(true);
            }
            else
            {
                DataEvents.InvokeConnectionStatus(true);
            }

            return(result);
        }
Ejemplo n.º 20
0
        internal static string BuildChannelError(IClientInputChannel channel, ConnectResult result, bool isException)
        {
            var messageBuilder = new StringBuilder();

            messageBuilder.Append(Strings.UnableToConnect);
            messageBuilder.Append(", ");

            if (isException)
            {
                messageBuilder.Append(Strings.DueToAnApplicationError);
            }
            else
            {
                switch (result)
                {
                case ConnectResult.AuthFailure:
                    messageBuilder.AppendFormat(Strings.ServerSaid, channel.AuthMessage);
                    break;

                default:
                    messageBuilder.Append(Strings.DueToAChannelError);
                    break;
                }
            }

            return(messageBuilder.ToString());
        }
        public void ShowError(ConnectResult connectResult)
        {
            switch (connectResult)
            {
            case ConnectResult.Timeout:
            case ConnectResult.InvalidEndpoint:
            case ConnectResult.InvalidSocket:
            case ConnectResult.SocketError:
            {
                var messageBox = _messageBoxFactory.CreateMessageBox(DialogResourceID.CONNECTION_SERVER_NOT_FOUND,
                                                                     EODialogButtons.Ok,
                                                                     EOMessageBoxStyle.SmallDialogLargeHeader);
                messageBox.ShowDialog();
            }
            break;

            default:
            {
                var errorCode = (int)connectResult;
                var ex        = new SocketException(errorCode);

                var messageBox = _messageBoxFactory.CreateMessageBox(
                    $"Error code from socket: {ex.SocketErrorCode}",
                    "Internal Error");
                messageBox.ShowDialog();
            }
            break;
            }
        }
Ejemplo n.º 22
0
 void ShowChannelError(ConnectResult result, bool isException)
 {
     ClientState.Current.ShowMessage(
         new AppMessage(ExceptionHelper.BuildChannelError(channel, result, isException))
     {
         SourceChannelId = config.ChannelId
     }, MessageType.Error);
 }
Ejemplo n.º 23
0
        // This is executed in a new thread each time, so it is safe to use blocking calls
        protected override void OnIncomingCall(Call call)
        {
            Console.WriteLine("Answering");

            // Answer the incoming call, block until it's answered or an error occurs
            AnswerResult resultAnswer = call.Answer();

            if (!resultAnswer.Successful)
            {
                // The call was not answered successfully, stop the consumer and bail out
                Stop();
                return;
            }

            call.PlayTTS("Welcome to SignalWire!");

            Console.WriteLine("Connecting");

            // Connect the inbound call to an outbound call
            ConnectResult resultConnect = call.Connect(new List <List <CallDevice> >
            {
                new List <CallDevice>
                {
                    new CallDevice
                    {
                        Type       = CallDevice.DeviceType.phone,
                        Parameters = new CallDevice.PhoneParams
                        {
                            ToNumber   = "+1555XXXXXXX",
                            FromNumber = "+1555XXXXXXX",
                        }
                    }
                }
            });

            if (resultConnect.Successful)
            {
                Console.WriteLine("Connected");
                resultConnect.Call.PlayTTS("Welcome!");

                // Wait upto 15 seconds for the connected side to hangup
                if (!resultConnect.Call.WaitForEnded()) //TimeSpan.FromSeconds(15)))
                {
                    // If the other side of the outbound call doesn't hang up, then hang it up
                    resultConnect.Call.Hangup();
                }
            }

            call.PlayTTS("Thank you for trying SignalWire!");

            // Hangup the inbound call
            call.Hangup();

            // Stop the consumer
            Stop();
        }
Ejemplo n.º 24
0
        public void onResult(string p0, ConnectResult resultObject)
        {
            Debug.Log("[HMS] NearbyManager onResult");

            if (resultObject.Status.StatusCode == StatusCode.STATUS_SUCCESS)
            {
                Debug.Log("[HMS] NearbyManager Connection Established. Stop discovery. Start to send file.");
            }
            nearbyManagerObject.OnResult?.Invoke(p0, resultObject);
        }
Ejemplo n.º 25
0
 void microphoneConnector1_ConnectEnded(ConnectResult result)
 {
     this.microConnect = result == ConnectResult.Succeed ? true : false;
     if (microConnect.Value)
     {
         //音频连接成功的时候初始化 信号控件
         this.channelQualityDisplayer1.Initialize(this.friendName);
     }
     this.DealConnectResult();
 }
Ejemplo n.º 26
0
        private void comboBox_Server_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.comboBox_Server.Text.ToString().Trim() != "0.0.0.0")
            {
                #region 設定IP、Port顯示
                this.NumericUpDown_Port.Value = this.MyServerList[this.comboBox_Server.SelectedIndex].ServerPort;
                if (this.MyServerList[this.comboBox_Server.SelectedIndex].IsMaster)
                {
                    this.checkBox_IsMaster.Checked = true;
                }
                else
                {
                    this.checkBox_IsMaster.Checked = false;
                }

                #endregion

                #region  測試是否可鏈接 Test connect click event procedure.
                // set result to default value ..
                resultVar = ConnectResult.NONE;
                // lock controls ..
                this.FormControls(false);

                // 獲取地址 analysis server address ..

                IPAddress[] ipadds = Dns.GetHostAddresses(this.comboBox_Server.Text.Trim());

                if (ipadds.Length > 0)
                {
                    // assign ip address ..
                    this.Addr = ipadds[0];

                    //創建新的線程鏈接伺服器 create therad object ..
                    __Connect = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(this.Connecting));

                    // start thread process and timer check ..
                    __Connect.Start(ipadds[0]);
                    __reply.Start();
                }
                else
                {
                    MessageBox.Show(this.ParseErrMsg, AssemblyInfoClass.ProductInfo, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    // unlock controls ..
                    this.FormControls(true);
                    return;
                }
            }
            else
            {
                MessageBox.Show("未指定的位址");
            }
            #endregion
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 连接结束事件
 /// </summary>
 /// <param name="result"></param>
 private void OnConnectEnded(ConnectResult result)
 {
     if (result == ConnectResult.Succeed)
     {
         ConnectEnded?.Invoke(new Result(baseResult.Successful));
     }
     else
     {
         ConnectEnded?.Invoke(new Result(baseResult.Faild, result.ToString()));
     }
 }
Ejemplo n.º 28
0
        public ConnectResult TryConnect(string portName, bool sayhello)
        {
            if (portName == "")
            {
                return(ConnectResult.InvalidArgument);
            }
            Disconnect();
            EventWaitHandle ewh    = new EventWaitHandle(false, EventResetMode.AutoReset);
            ConnectResult   result = ConnectResult.None;

            Arduino                = new ArduinoSerial(portName);
            Arduino.BytesSent     += (port, bytes) => BytesSent?.Invoke(port, bytes);
            Arduino.BytesReceived += (port, bytes) => BytesReceived?.Invoke(port, bytes);
            ArduinoSerial.StatusChangedHandler statuschanged = status =>
            {
                lock (ewh)
                {
                    if (result != ConnectResult.None)
                    {
                        return;
                    }
                    if (status == ArduinoSerial.Status.Connected || status == ArduinoSerial.Status.ConnectedUnsafe)
                    {
                        result = ConnectResult.Success;
                        ewh.Set();
                    }
                    if (status == ArduinoSerial.Status.Error)
                    {
                        result = ConnectResult.Error;
                        ewh.Set();
                    }
                }
            };
            Arduino.StatusChanged += statuschanged;
            Arduino.Connect(sayhello);
            if (!ewh.WaitOne(300) && sayhello)
            {
                Arduino.Disconnect();
                Arduino = null;
                return(ConnectResult.Timeout);
            }
            if (result != ConnectResult.Success)
            {
                Arduino.Disconnect();
                Arduino = null;
                return(result);
            }
            Arduino.StatusChanged -= statuschanged;
            _thread = new Thread(Loop);
            _thread.IsBackground = true;
            _thread.Start();
            return(ConnectResult.Success);
        }
Ejemplo n.º 29
0
 void MicrophoneConnector_ConnectEnded(ConnectResult res)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new CbGeneric <ConnectResult>(this.MicrophoneConnector_ConnectEnded), res);
     }
     else
     {
         this.connectResult = res;
         this.ShowMicState();
     }
 }
Ejemplo n.º 30
0
 void MicrophoneConnector_ConnectEnded(ConnectResult res)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new CbGeneric<ConnectResult>(this.MicrophoneConnector_ConnectEnded), res);
     }
     else
     {
         this.connectResult = res;
         this.ShowMicState();
     }
 }
Ejemplo n.º 31
0
 //摄像头连接器尝试连接的结果
 void DynamicCameraConnector_ConnectEnded(ConnectResult res)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new CbGeneric <ConnectResult>(this.DynamicCameraConnector_ConnectEnded), res);
     }
     else
     {
         this.label_tip.Visible   = false;
         this.connectCameraResult = res;
         this.ShowCameraState();
     }
 }
Ejemplo n.º 32
0
        public async Task ConnectToCFAsync_ReturnsConnectResult_WhenLoginFails()
        {
            mockCfApiClient.Setup(mock => mock.LoginAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync((string)null);
            mockCfCliService.Setup(mock => mock.ExecuteCfCliCommandAsync(It.IsAny <string>(), It.IsAny <StdOutDelegate>(), It.IsAny <string>())).ReturnsAsync(new DetailedResult(true));

            ConnectResult result = await cfService.ConnectToCFAsync(fakeValidTarget, fakeValidUsername, fakeValidPassword, fakeHttpProxy, skipSsl);

            Assert.IsFalse(result.IsLoggedIn);
            Assert.IsTrue(result.ErrorMessage.Contains(cfService.LoginFailureMessage));
            Assert.IsNull(result.Token);
            mockCfApiClient.Verify(mock => mock.LoginAsync(fakeValidTarget, fakeValidUsername, It.IsAny <string>()), Times.Once);
            mockCfCliService.VerifyAll();
        }
Ejemplo n.º 33
0
        private PackageCatalog GetPackageCatalog(CompositeSearchBehavior behavior)
        {
            PackageCatalogReference reference = this.GetPackageCatalogReference(behavior);
            ConnectResult           result    = reference.Connect();

            if (result.Status == ConnectResultStatus.Ok)
            {
                return(result.PackageCatalog);
            }
            else
            {
                throw new RuntimeException(Utilities.ResourceManager.GetString("RuntimeExceptionCatalogError"));
            }
        }
Ejemplo n.º 34
0
        /// <summary>
        /// 获取ConnectResult枚举值对应的中文描述。
        /// </summary>
        public static string GetDescription(ConnectResult connectResult)
        {
            if (connectResult == ConnectResult.Succeed)
            {
                return("Succeed:连接成功。");
            }
            if (connectResult == ConnectResult.CantConnectRepeatly)
            {
                return("CantConnectRepeatly:不能重复连接同一设备!");
            }
            if (connectResult == ConnectResult.ChannelUnavailable)
            {
                return("ChannelUnavailable:通道不可用,当前客户端与OMCS服务器之间的连接尚未建立或已经断开!");
            }
            if (connectResult == ConnectResult.DeviceInUsing)
            {
                return("DeviceInUsing:要连接的目标设备已经被其它程序占用!");
            }
            if (connectResult == ConnectResult.DeviceInvalid)
            {
                return("DeviceInvalid:要连接的目标设备不存在或不可用!");
            }
            if (connectResult == ConnectResult.DeviceUnauthorized)
            {
                return("DeviceUnauthorized:本次OMCS授权不包含目标设备类型!");
            }
            if (connectResult == ConnectResult.ExceptionOccured)
            {
                return("ExceptionOccured:在连接的过程中出现了异常!");
            }
            if (connectResult == ConnectResult.OwnerNotInitialized)
            {
                return("MultimediaManagerNotInitialized目标设备主人的多媒体管理器还未完成初始化!");
            }
            if (connectResult == ConnectResult.SelfOffline)
            {
                return("SelfOffline:在连接的过程中,当前客户端与OMCS服务器之间的连接已经断开!");
            }
            if (connectResult == ConnectResult.TargetUserOffline)
            {
                return("TargetUserOffline:在连接的过程中,对方与OMCS之间的连接已经断开!");
            }
            if (connectResult == ConnectResult.Timeout)
            {
                return("Timeout:等待对方回复超时!");
            }

            return("");
        }
Ejemplo n.º 35
0
 void whiteBoardConnector1_ConnectEnded(ConnectResult result)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new CbGeneric<ConnectResult>(this.whiteBoardConnector1_ConnectEnded), result);
     }
     else
     {
         if (result != ConnectResult.Succeed)
         {
             MessageBox.Show("连接失败!" + result.ToString());
             return;
         }
     }
 }
Ejemplo n.º 36
0
        /// <summary>
        /// 鏈接指定地址的服務器 Connect remote server thread event.
        /// </summary>
        /// <param name="address">test address.</param>
        private void Connecting(object address)
        {
            // create connect remote machine class object instance ..
            ScanPort runConnect = new ScanPort();

            // 測試是否可連接 scanning ..
            if (!runConnect.Scan((IPAddress)address, (ushort)this.NumericUpDown_Port.Value))
            {
                resultVar = ConnectResult.FAILCONNECT;
            }
            else
            {
                resultVar = ConnectResult.SUCCESS;
            }
        }
Ejemplo n.º 37
0
        public async Task<ConnectResult> TryConnectAsync(AsyncTcpConnector connector, int milliseconds)
        {
            var result = new ConnectResult { TimerTask = Task.Delay(milliseconds, Token) };

            try
            {
                task = connector.ConnectAsync(tcp);
                if (task == await Task.WhenAny(task, result.TimerTask).ConfigureAwait(false))
                {
                    await task;
                    stream = tcp.GetStream();
                    result.Connected = true;
                }
            }
            catch (SocketException)
            {
                // ignore
            }

            return result;
        }
Ejemplo n.º 38
0
 private void connectWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     DbConnection cn = _factory.CreateConnection();
     cn.ConnectionString = _connection.ConnectionString;
     _connection.OpenConnection = cn;
     try
     {
         cn.Open();
         ConnectResult r = new ConnectResult();
         r.Success = true;
         r.Message = SR.ConnectSuccess;
         e.Result = r;
     }
     catch (Exception ex)
     {
         ConnectResult r = new ConnectResult();
         r.Success = false;
         r.Message = SR.ConnectFail + "\r\n\r\n" + ex.GetBaseException().Message;
         e.Result = r;
     }
 }
Ejemplo n.º 39
0
 void ShowChannelError(ConnectResult result, bool isException)
 {
     ClientState.Current.ShowMessage(
         new AppMessage(ExceptionHelper.BuildChannelError(channel, result, isException))
             {
                 SourceChannelId = config.ChannelId
             }, MessageType.Error);
 }
 public ChannelConnectException(ConnectResult result, string authMessage)
     : base(string.Empty)
 {
     this.result = result;
     this.authMessage = authMessage;
 }
Ejemplo n.º 41
0
 private void microphoneConnector1_ConnectEnded(ConnectResult res)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new CbGeneric<ConnectResult>(this.microphoneConnector1_ConnectEnded), res);
     }
     else
     {
         if (res != ConnectResult.Succeed)
         {
             this.decibelDisplayer_speaker.Working = false;
             this.decibelDisplayer_speaker.Error = true;
         }
     }
 }
Ejemplo n.º 42
0
        private void dynamicCameraConnector1_ConnectEnded(ConnectResult res)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new CbGeneric<ConnectResult>(this.dynamicCameraConnector1_ConnectEnded), res);
            }
            else
            {
                try
                {
                    this.skinPanel_tool.Visible = true;
                    this.skinLabel_tip.Visible = false;
                    this.timerLabel1.Start();

                    if (res == ConnectResult.Succeed)
                    {
                        this.skinCheckBox_HighR.Visible = true;

                        int sum = this.dynamicCameraConnector1.VideoSize.Width + this.dynamicCameraConnector1.VideoSize.Height;
                        int delt1 = Math.Abs(sum - GlobalConsts.CommonQualityVideo);
                        int delt2 = Math.Abs(sum - GlobalConsts.HighQualityVideo);

                        this.skinCheckBox_HighR.CheckState = delt2 < delt1 ? CheckState.Checked : CheckState.Unchecked;

                        this.button_record.Visible = true;
                    }
                    else
                    {
                        this.skinCheckBox_HighR.Visible = false;
                        this.skinLabel_cameraError.Text = res.ToString();
                        this.skinLabel_cameraError.Visible = true;
                    }
                }
                catch (Exception ee)
                {
                    GlobalResourceManager.Logger.Log(ee, "dynamicCameraConnector1_ConnectEnded", ESBasic.Loggers.ErrorLevel.Standard);
                    MessageBox.Show(ee.Message + " - " + ee.StackTrace);
                }
            }
        }
Ejemplo n.º 43
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Result = (ConnectResult)reader.ReadByte();
     KeyboardEncryption = reader.ReadBool();
     MouseEncryption = reader.ReadBool();
 }
Ejemplo n.º 44
0
 void microphoneConnector1_ConnectEnded(ConnectResult res)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new CbGeneric<ConnectResult>(this.microphoneConnector1_ConnectEnded), res);
     }
     else
     {
         if (res != ConnectResult.Succeed)
         {
             this.label_error2.Visible = true;
             this.label_error2.Text = res.ToString();
         }
         else
         {
             this.label_error2.Visible = false;
         }
     }
 }
Ejemplo n.º 45
0
 void cameraConnector1_ConnectEnded(ConnectResult res)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke(new CbGeneric<ConnectResult>(this.cameraConnector1_ConnectEnded), res);
     }
     else
     {
         if (res != ConnectResult.Succeed)
         {
             this.label_error.Visible = true;
             this.label_error.Text = res.ToString();
         }
         else
         {
             this.label_error.Visible = false;
         }
         this.label_info.Visible = false;
         this.Cursor = Cursors.Default;
     }
 }