Ejemplo n.º 1
0
    private void Update()
    {
        bool       flag      = false;
        Connecting component = GetComponent <Connecting>();

        if (null != component)
        {
            flag = component.Show;
        }
        Screen.lockCursor = (!Application.isLoadingLevel && !battleChat.IsChatting && !DialogManager.Instance.IsModal && !flag);
        if (delayLoad)
        {
            deltaTime += Time.deltaTime;
            if (deltaTime > 1f)
            {
                delayLoad = false;
                StartLoad();
            }
        }
        else if (!Application.isLoadingLevel)
        {
            if (!battleChat.IsChatting && BrickManager.Instance.IsLoaded && custom_inputs.Instance.GetButtonDown("K_MAIN_MENU") && !DialogManager.Instance.IsPopup(DialogManager.DIALOG_INDEX.MENU_EX) && GlobalVars.Instance.IsMenuExOpenOk())
            {
                ((MenuEx)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.MENU_EX, exclusive: true))?.InitDialog();
                if (MyInfoManager.Instance.Seq == RoomManager.Instance.Master)
                {
                    BrickManDesc[] array = BrickManManager.Instance.ToDescriptorArrayWhoTookTooLongToWait();
                    if (array != null && array.Length > 0)
                    {
                        DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.KICK, exclusive: false);
                    }
                }
            }
            if (custom_inputs.Instance.GetButtonDown("K_HELP") && !DialogManager.Instance.IsModal && GlobalVars.Instance.IsMenuExOpenOk() && !battleChat.IsChatting)
            {
                DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.HELPWINDOW, exclusive: true);
            }
            GlobalVars.Instance.UpdateFlashbang();
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="et"></param>
        /// <param name="arg"></param>
        private void CompleteProcessing(EventEntry entry)
        {
            switch (entry.Type)
            {
            case EventType.Connecting:
                Connecting?.Invoke(this, ( int )entry.Argument);
                break;

            case EventType.Listening:
                Listening?.Invoke(this, ( int )entry.Argument);
                break;

            case EventType.Connected:
                Connected?.Invoke(this, ( int )entry.Argument);
                break;

            case EventType.Disconnected:
                Disconnected?.Invoke(this, ( int )entry.Argument);
                break;

            case EventType.Terminated:
                Terminated?.Invoke(this, EventArgs.Empty);
                break;

            case EventType.Sent:
                Sent?.Invoke(this, (Tuple <byte [], Message>)entry.Argument);
                break;

            case EventType.Received:
                Received?.Invoke(this, (Tuple <byte [], Message>)entry.Argument);
                break;

            case EventType.T3Timeout:
                T3Timeout?.Invoke(this, ( Message )entry.Argument);
                break;

            default: break;
            }
        }
 void ReleaseDesignerOutlets()
 {
     if (Activity != null)
     {
         Activity.Dispose();
         Activity = null;
     }
     if (Connecting != null)
     {
         Connecting.Dispose();
         Connecting = null;
     }
     if (ErrorLabel != null)
     {
         ErrorLabel.Dispose();
         ErrorLabel = null;
     }
     if (RetryButton != null)
     {
         RetryButton.Dispose();
         RetryButton = null;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Method used to connect to the Simias server.
        /// </summary>
        /// <returns><b>True</b> if successfully connected; otherwise, <b>False</b> is returned.</returns>
        public bool ConnectToServer()
        {
            bool result = false;

            Connecting connecting = new Connecting(this.ifWebService, simiasWebService, simiasManager, serverPage.ServerAddress, identityPage.Username, identityPage.Password, serverPage.DefaultServer, identityPage.RememberPassword);

            connecting.EnterpriseConnect += new Novell.FormsTrayApp.Connecting.EnterpriseConnectDelegate(connecting_EnterpriseConnect);
            if (connecting.ShowDialog() == DialogResult.OK)
            {
                result     = true;
                domainInfo = connecting.DomainInformation;
                this.defaultiFolderPage.DomainInfo   = this.domainInfo;
                this.defaultiFolderPage.defaultPath  = this.GetDefaultPath(this.identityPage.Username, this.defaultiFolderPage.DomainInfo.Name);
                this.defaultiFolderPage.defaultPath += "\\" + Resource.GetString("DefaultDirName") + "_" + this.identityPage.Username;
                Novell.FormsTrayApp.FormsTrayApp.globalProp().updateifListViewDomainStatus(domainInfo.ID, domainInfo.Authenticated);
                if (true == domainInfo.Authenticated)
                {
                    Novell.FormsTrayApp.FormsTrayApp.globalProp().AddDomainToUIList(domainInfo);
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        public void Connect()
        {
            _remoteClient.OnConnected += (s, e) =>
            {
                Console.WriteLine("Connected to remoteServer");
                ((Client)s).thread.Abort();
                var serverIP = GetIP();
                if (serverIP != null)
                {
                    _vanillaClient.Connect(serverIP, 8080);
                }
                else
                {
                    Reconnect();
                }
            };

            _vanillaClient.OnConnected  += (o, e) => _vanillaClient.Send(new ClientVersionCheck(Config.MAJOR, Config.MINOR, Config.BUILD));
            _vanillaClient.Disconnected += (o, e) => Reconnect();
            _remoteClient.Disconnected  += (o, e) => Reconnect();

            Connecting?.Invoke(this, EventArgs.Empty);
            _remoteClient.Connect(_ip, 8082);
        }
Ejemplo n.º 6
0
 private void RaiseConnecting()
 {
     // Not posted to Unity's main thread as this
     // should be already called from it
     Connecting?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Called before the network connects to the server.
 /// </summary>
 /// <param name="sender">The sender instance.</param>
 /// <param name="ev">The <see cref="ConnectingEventArgs"/> instance.</param>
 protected virtual void OnConnecting(object sender, ConnectingEventArgs ev) => Connecting?.Invoke(sender, ev);
Ejemplo n.º 8
0
 private void ChannelConnecting(IChannel channel)
 {
     Connecting?.Invoke(this, new ConnectingEventArgs {
         Binding = channel.Binding, Socket = this
     });
 }
Ejemplo n.º 9
0
            public void ProcessPackets()
            {
                while (_messageChannel.Reader.TryRead(out var item))
                {
                    switch (item)
                    {
                    case ConnectMessage connect:
                    {
                        DebugTools.Assert(IsServer);

                        var writer = connect.ChannelWriter;

                        var uid       = _genConnectionUid();
                        var sessionId = new NetSessionId($"integration_{uid}");

                        var connectArgs =
                            new NetConnectingArgs(sessionId, new IPEndPoint(IPAddress.IPv6Loopback, 0));
                        Connecting?.Invoke(this, connectArgs);
                        if (connectArgs.Deny)
                        {
                            writer.TryWrite(new DeniedConnectMessage());
                            continue;
                        }

                        writer.TryWrite(new ConfirmConnectMessage(uid, sessionId));
                        var channel = new IntegrationNetChannel(this, connect.ChannelWriter, uid, sessionId, connect.Uid);
                        _channels.Add(uid, channel);
                        Connected?.Invoke(this, new NetChannelArgs(channel));
                        break;
                    }

                    case DataMessage data:
                    {
                        IntegrationNetChannel?channel;
                        if (IsServer)
                        {
                            if (!_channels.TryGetValue(data.Connection, out channel))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (ServerChannel == null || data.Connection != ServerChannel.ConnectionUid)
                            {
                                continue;
                            }

                            channel = ServerChannel;
                        }

                        var message = data.Message;
                        message.MsgChannel = channel;
                        if (_callbacks.TryGetValue(message.GetType(), out var callback))
                        {
                            callback(message);
                        }

                        break;
                    }

                    case DisconnectMessage disconnect:
                    {
                        if (IsServer)
                        {
                            if (_channels.TryGetValue(disconnect.Connection, out var channel))
                            {
                                Disconnect?.Invoke(this, new NetDisconnectedArgs(channel, string.Empty));

                                _channels.Remove(disconnect.Connection);
                            }
                        }
                        else
                        {
                            _channels.Clear();
                        }

                        break;
                    }

                    case DeniedConnectMessage _:
                    {
                        DebugTools.Assert(IsClient);

                        ConnectFailed?.Invoke(this, new NetConnectFailArgs("I didn't implement a deny reason!"));
                        break;
                    }

                    case ConfirmConnectMessage confirm:
                    {
                        DebugTools.Assert(IsClient);

                        var channel = new IntegrationNetChannel(this, NextConnectChannel !, _clientConnectingUid,
                                                                confirm.SessionId, confirm.AssignedUid);

                        _channels.Add(channel.ConnectionUid, channel);

                        Connected?.Invoke(this, new NetChannelArgs(channel));
                        break;
                    }

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
Ejemplo n.º 10
0
 /// <summary>
 /// ShowWait Dialog
 /// </summary>
 private void ShowWaitDialog()
 {
     waitWindow = new Connecting();
     waitWindow.ShowDialog();
 }
Ejemplo n.º 11
0
        /// <summary>
        ///     Try connecting to the remote host
        /// </summary>
        private void Connect()
        {
            Logger.WriteDebug($"{decoderName}: connect -> start");
            //Set status
            decoderStatus = ConnectionStatus.Connecting;
            //Raise event
            Connecting.RaiseEvent(this, null);

            try
            {
                //Release decoder
                if (decoderSocket != null)
                {
                    decoderSocket.Close();
                    decoderSocket = null;
                }

                //Parse server host/ip
                Logger.WriteDebug($"{decoderName}: connect -> server({decoderServer})");
                if (Regex.IsMatch(decoderServer,
                                  @"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
                    )
                {
                    // the string is a IP
                    decoderIpAddress = IPAddress.Parse(decoderServer);
                }
                else if (Regex.IsMatch(decoderServer,
                                       @"^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$"))
                {
                    // the string is a host -> try to resolve
                    var _ipHostInfo = Dns.GetHostEntry(decoderServer);
                    foreach (var ipAdress in _ipHostInfo.AddressList)
                    {
                        if (Regex.IsMatch(ipAdress.ToString(),
                                          @"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$")
                            )
                        {
                            decoderIpAddress = ipAdress;
                            break;
                        }
                    }

                    //If resolve fail -> abort
                    if (decoderIpAddress == null)
                    {
                        Logger.WriteDebug($"{decoderName}: cannot resolve hostname {decoderServer}");
                        Disconnected.RaiseEvent(this, null);
                        return;
                    }
                }

                Logger.WriteDebug($"{decoderName}: connect -> ip({decoderIpAddress})");

                //Create a TCP/IP socket
                var _remoteEP = new IPEndPoint(decoderIpAddress, decoderPort);
                decoderSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                //Start timer for timeout
                connectTimeout.Start();
                //Connect to the remote endpoint
                decoderSocket.BeginConnect(_remoteEP, ConnectCallback, decoderSocket);
            }
            catch (SocketException ex)
            {
                Logger.WriteDebug($"{decoderName}: connect -> {ex.Message}");

                //Start reconnect
                Reconnect();
            }
            catch (Exception ex)
            {
                Logger.WriteDebug($"{decoderName}: {ex} -> {ex.Message}");
            }
        }
Ejemplo n.º 12
0
        protected virtual void OnConnecting(object sender, EventArgs args)
        {
            Console.WriteLine("Terminal {0}: connected.\n", this.Number);

            Connecting?.Invoke(sender, args);
        }
Ejemplo n.º 13
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Connecting obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Ejemplo n.º 14
0
        public void testGetThreadId()
        {
            ConnectionsV1_0 connecting = Connecting.v1_0(label, base64Url);

            Assert.IsNotNull(connecting.getThreadId());
        }
Ejemplo n.º 15
0
 private void OnConnecting()
 {
     Connecting?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 16
0
 public static void ToLoginScene()
 {
     Connecting.GetInst().ForceHide();
     SceneLoader.ToLoginScene(true);
 }
Ejemplo n.º 17
0
 internal void OnConnecting(EndPoint endpoint, ConnectionType connectionType) => Connecting?.Invoke(endpoint, connectionType);
Ejemplo n.º 18
0
    private void Update()
    {
        bool       flag      = false;
        Connecting component = GetComponent <Connecting>();

        if (null != component)
        {
            flag = component.Show;
        }
        Screen.lockCursor = (!Application.isLoadingLevel && !battleChat.IsChatting && !DialogManager.Instance.IsModal && !flag);
        if (delayLoad)
        {
            deltaTime += Time.deltaTime;
            if (deltaTime > 1f)
            {
                delayLoad = false;
                StartLoad();
            }
        }
        else if (!Application.isLoadingLevel)
        {
            if (statusMessage.Length > 0)
            {
                statusDelta += Time.deltaTime;
                if (statusDelta > statusMessageLimit)
                {
                    statusDelta   = 0f;
                    statusMessage = string.Empty;
                }
            }
            if (!battleChat.IsChatting && BrickManager.Instance.IsLoaded && custom_inputs.Instance.GetButtonDown("K_MAIN_MENU") && !DialogManager.Instance.IsPopup(DialogManager.DIALOG_INDEX.MENU_EX) && GlobalVars.Instance.IsMenuExOpenOk())
            {
                ((MenuEx)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.MENU_EX, exclusive: true))?.InitDialog();
                if (MyInfoManager.Instance.Seq == RoomManager.Instance.Master)
                {
                    BrickManDesc[] array = BrickManManager.Instance.ToDescriptorArrayWhoTookTooLongToWait();
                    if (array != null && array.Length > 0)
                    {
                        DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.KICK, exclusive: false);
                    }
                }
            }
            if (custom_inputs.Instance.GetButtonDown("K_HELP") && !DialogManager.Instance.IsModal && GlobalVars.Instance.IsMenuExOpenOk() && !battleChat.IsChatting)
            {
                DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.HELPWINDOW, exclusive: true);
            }
            GlobalVars.Instance.UpdateFlashbang();
        }
        if (!bRounding && bLoaded)
        {
            VerifyLocalController();
            if (localController.checkResetFlag)
            {
                localController.dtResetFlag += Time.deltaTime;
                if (localController.dtResetFlag > dtResetFlagmax && BrickManager.Instance.userMap != null)
                {
                    SpawnerDesc spawner = BrickManager.Instance.userMap.GetSpawner(Brick.SPAWNER_TYPE.FLAG_SPAWNER, 0);
                    Vector3     vector  = new Vector3(spawner.position.x, spawner.position.y - 0.3f, spawner.position.z);
                    CSNetManager.Instance.Sock.SendCS_CTF_FLAG_RETURN_REQ(vector.x, vector.y, vector.z);
                    localController.checkResetFlag = false;
                }
            }
            if (strVoiceName.Length > 0)
            {
                deltaTimeDelaySound += Time.deltaTime;
                if (deltaTimeDelaySound > deltaTimeDelaySoundMax)
                {
                    VoiceManager.Instance.Play(strVoiceName);
                    strVoiceName = string.Empty;
                }
            }
            if (BrickManManager.Instance.bSendTcpCheckOnce)
            {
                deltaTimeTcp += Time.deltaTime;
                if (deltaTimeTcp > 1f)
                {
                    BrickManManager.Instance.bSendTcpCheckOnce = false;
                }
            }
            if (!UpdateSuccessfulCaptureTheFlag())
            {
                if (BrickManManager.Instance.haveFlagSeq >= 0)
                {
                    if (BrickManManager.Instance.haveFlagSeq == MyInfoManager.Instance.Seq)
                    {
                        SpawnerDesc spawnerDesc = (MyInfoManager.Instance.Slot >= 8) ? BrickManager.Instance.userMap.GetSpawner(Brick.SPAWNER_TYPE.RED_FLAG_SPAWNER, 0) : BrickManager.Instance.userMap.GetSpawner(Brick.SPAWNER_TYPE.BLUE_FLAG_SPAWNER, 0);
                        float       num         = Vector3.Distance(me.transform.position, spawnerDesc.position);
                        int         num2        = 0;
                        if (IsRedTeam(MyInfoManager.Instance.Seq))
                        {
                            num2 = 1;
                        }
                        Vector3 position  = rbPlanes[num2].transform.position;
                        float   y         = position.y;
                        Vector3 position2 = me.transform.position;
                        float   num3      = y - position2.y;
                        FlagObj.transform.position = new Vector3(0f, -10000f, 0f);
                        if (!BrickManManager.Instance.bSendTcpCheckOnce && num3 < 0.7f && num < 3.2f)
                        {
                            CSNetManager.Instance.Sock.SendCS_CTF_CAPTURE_FLAG_REQ(captureTheFlag, opponent: true);
                            BrickManManager.Instance.bSendTcpCheckOnce = true;
                            deltaTimeTcp = 0f;
                        }
                    }
                    else
                    {
                        GameObject gameObject = BrickManManager.Instance.Get(BrickManManager.Instance.haveFlagSeq);
                        if ((bool)gameObject)
                        {
                            Transform[] componentsInChildren = gameObject.GetComponentsInChildren <Transform>();
                            int         num4 = 0;
                            while (true)
                            {
                                if (num4 >= componentsInChildren.Length)
                                {
                                    return;
                                }
                                if (componentsInChildren[num4].name.Contains("dummy_water"))
                                {
                                    break;
                                }
                                num4++;
                            }
                            FlagObj.transform.position = componentsInChildren[num4].position;
                            FlagObj.transform.rotation = gameObject.transform.rotation;
                        }
                    }
                }
                else if (!localController.IsDead && !BrickManManager.Instance.bSendTcpCheckOnce)
                {
                    float   num5      = Vector3.Distance(me.transform.position, FlagObj.transform.position);
                    Vector3 position3 = FlagObj.transform.position;
                    float   y2        = position3.y;
                    Vector3 position4 = me.transform.position;
                    float   num6      = y2 - position4.y;
                    if (num6 < 0.7f && num5 < 1.8f)
                    {
                        CSNetManager.Instance.Sock.SendCS_CTF_PICK_FLAG_REQ(captureTheFlag);
                        BrickManManager.Instance.bSendTcpCheckOnce = true;
                        deltaTimeTcp = 0f;
                    }
                }
            }
        }
    }
Ejemplo n.º 19
0
        private BluetoothImpl()
        {
            try
            {
                if (PlatformUtils.IsWindows && SettingsProvider.Instance.UseBluetoothWinRT &&
                    PlatformUtils.IsWindowsContractsSdkSupported)
                {
                    Log.Debug("BluetoothImpl: Using WinRT.BluetoothService");
                    _backend = new Bluetooth.WindowsRT.BluetoothService();
                }
#if WindowsNoARM
                else if (PlatformUtils.IsWindows)
                {
                    Log.Debug("BluetoothImpl: Using Windows.BluetoothService");
                    _backend = new Bluetooth.Windows.BluetoothService();
                }
#else
                else if (PlatformUtils.IsWindows && PlatformUtils.IsWindowsContractsSdkSupported)
                {
                    Log.Debug("BluetoothImpl: Using WinRT.BluetoothService (ARM)");
                    _backend = new Bluetooth.WindowsRT.BluetoothService();
                }
#endif
                else if (PlatformUtils.IsLinux)
                {
                    Log.Debug("BluetoothImpl: Using Linux.BluetoothService");
                    _backend = new Bluetooth.Linux.BluetoothService();
                }
                else
                {
                    Log.Warning("BluetoothImpl: Using Dummy.BluetoothService");
                    _backend = new Dummy.BluetoothService();
                }
            }
            catch (PlatformNotSupportedException)
            {
                Log.Error("BluetoothImpl: Critical error while preparing bluetooth backend");
                Log.Error("BluetoothImpl: Backend swapped out with non-functional dummy object in order to prevent crash");
                _backend = new Dummy.BluetoothService();
            }

            _cancelSource = new CancellationTokenSource();
            _loop         = Task.Run(DataConsumerLoop, _cancelSource.Token);

            _backend.Connecting          += (sender, args) => Connecting?.Invoke(this, EventArgs.Empty);
            _backend.NewDataAvailable    += OnNewDataAvailable;
            _backend.NewDataAvailable    += (sender, bytes) => NewDataReceived?.Invoke(this, bytes);
            _backend.BluetoothErrorAsync += (sender, exception) => OnBluetoothError(exception);

            _backend.RfcommConnected += (sender, args) => Task.Run(async() =>
                                                                   await Task.Delay(150).ContinueWith((_) =>
            {
                if (RegisteredDeviceValid)
                {
                    Connected?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    Log.Error("BluetoothImpl: Suppressing Connected event, device not properly registered");
                }
            }));

            _backend.Disconnected += (sender, reason) =>
            {
                if (!SuppressDisconnectionEvents)
                {
                    Disconnected?.Invoke(this, reason);
                }
            };

            MessageReceived += SPPMessageHandler.Instance.MessageReceiver;
        }
Ejemplo n.º 20
0
    private void Update()
    {
        bool       flag      = false;
        Connecting component = GetComponent <Connecting>();

        if (null != component)
        {
            flag = component.Show;
        }
        Screen.lockCursor = (!Application.isLoadingLevel && !battleChat.IsChatting && !DialogManager.Instance.IsModal && !flag);
        if (delayLoad)
        {
            deltaTime += Time.deltaTime;
            if (deltaTime > 1f)
            {
                delayLoad = false;
                StartLoad();
            }
        }
        else if (!Application.isLoadingLevel)
        {
            flickerRed.Update();
            flickerBlue.Update();
            if (MyInfoManager.Instance.CheckControllable() && !bDelayBattle)
            {
                dtBattle += Time.deltaTime;
                if (dtBattle >= DefenseManager.Instance.GetWaveTable().interval)
                {
                    bDelayBattle = true;
                    DefenseManager.Instance.CurWave++;
                }
            }
            if (MyInfoManager.Instance.Seq == RoomManager.Instance.Master && bDelayBattle)
            {
                monGenDeltaTime += Time.deltaTime;
                if (monGenDeltaTime >= DefenseManager.Instance.GetWaveTable().interval)
                {
                    MonManager.Instance.MonGenerateNew();
                    monGenDeltaTime = 0f;
                }
            }
            if (MonManager.Instance.BossUiQ.Count > 0 && !isOutQueue)
            {
                BossUiInfo bossUiInfo = MonManager.Instance.BossUiQ.Dequeue();
                strQueue   = bossUiInfo.msg;
                texQueue   = bossUiInfo.tex2d;
                nameQueue  = bossUiInfo.name;
                dmgQueue   = bossUiInfo.dmg;
                isOutQueue = true;
                dtQueue    = 0f;
            }
            if (isOutQueue)
            {
                dtQueue += Time.deltaTime;
                if (dtQueue > 5f)
                {
                    strQueue   = string.Empty;
                    isOutQueue = false;
                }
            }
            if (statusMessage.Length > 0)
            {
                statusDelta += Time.deltaTime;
                if (statusDelta > statusMessageLimit)
                {
                    statusDelta   = 0f;
                    statusMessage = string.Empty;
                }
            }
            if (!battleChat.IsChatting && BrickManager.Instance.IsLoaded && custom_inputs.Instance.GetButtonDown("K_MAIN_MENU") && !DialogManager.Instance.IsPopup(DialogManager.DIALOG_INDEX.MENU_EX) && GlobalVars.Instance.IsMenuExOpenOk())
            {
                ((MenuEx)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.MENU_EX, exclusive: true))?.InitDialog();
                if (MyInfoManager.Instance.Seq == RoomManager.Instance.Master)
                {
                    BrickManDesc[] array = BrickManManager.Instance.ToDescriptorArrayWhoTookTooLongToWait();
                    if (array != null && array.Length > 0)
                    {
                        DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.KICK, exclusive: false);
                    }
                }
            }
            if (custom_inputs.Instance.GetButtonDown("K_HELP") && !DialogManager.Instance.IsModal && GlobalVars.Instance.IsMenuExOpenOk() && !battleChat.IsChatting)
            {
                DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.HELPWINDOW, exclusive: true);
            }
        }
        GlobalVars.Instance.UpdateFlashbang();
    }
Ejemplo n.º 21
0
 /// <summary>
 /// Constructs a VerifyPage object.
 /// </summary>
 public MigrationVerifyPage( )
 {
     // This call is required by the Windows Form Designer.
     InitializeComponent();
     waitWindow = null;
 }
 public Connected(Connecting prev, IConnection connection) : base(prev)
 {
     _connection = connection;
 }
Ejemplo n.º 23
0
    private void Update()
    {
        bool       flag      = false;
        Connecting component = GetComponent <Connecting>();

        if (null != component)
        {
            flag = component.Show;
        }
        Screen.lockCursor = (!Application.isLoadingLevel && !PaletteManager.Instance.MenuOn && !battleChat.IsChatting && !DialogManager.Instance.IsModal && !flag);
        if (delayLoad)
        {
            deltaTime += Time.deltaTime;
            if (deltaTime > 1f)
            {
                delayLoad = false;
                StartLoad();
            }
        }
        else if (!Application.isLoadingLevel)
        {
            if (!battleChat.IsChatting && BrickManager.Instance.IsLoaded && custom_inputs.Instance.GetButtonDown("K_MAIN_MENU") && GlobalVars.Instance.IsMenuExOpenOk())
            {
                if (DialogManager.Instance.IsModal || PaletteManager.Instance.MenuOn)
                {
                    DialogManager.Instance.CloseAll();
                    PaletteManager.Instance.Switch(on: false);
                }
                else
                {
                    ((MenuEx)DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.MENU_EX, exclusive: true))?.InitDialog();
                    if (MyInfoManager.Instance.Seq == RoomManager.Instance.Master)
                    {
                        BrickManDesc[] array = BrickManManager.Instance.ToDescriptorArrayWhoTookTooLongToWait();
                        if (array != null && array.Length > 0)
                        {
                            DialogManager.Instance.Popup(DialogManager.DIALOG_INDEX.KICK, exclusive: false);
                        }
                    }
                }
            }
            if (!battleChat.IsChatting && DialogManager.Instance.IsPopup(DialogManager.DIALOG_INDEX.MAPEDIT_AUTHORITY) && Input.GetKeyDown(KeyCode.Escape))
            {
                GlobalVars.Instance.SetForceClosed(set: true);
                DialogManager.Instance.CloseAll();
            }
        }
        if (listEffectivePoint.Count > 0)
        {
            int num = 0;
            while (num < listEffectivePoint.Count)
            {
                listEffectivePoint[num].time += Time.deltaTime;
                if (listEffectivePoint[num].time > 1f)
                {
                    listEffectivePoint.RemoveAt(num);
                }
                else
                {
                    num++;
                }
            }
        }
    }
Ejemplo n.º 24
0
        public static void Connect(Context context)
        {
            Connecting?.Invoke(null, EventArgs.Empty);

            Device.ConnectGatt(context, false, gattCallback);
        }
Ejemplo n.º 25
0
        public async Task ConnectAsync(string macAddress, string uuid, bool noRetry = false)
        {
            var semResult = await _connSemaphore.WaitAsync(5000);

            if (semResult == false)
            {
                Log.Error($"Windows.BluetoothService: Connection attempt timed out due to blocked semaphore");
                throw new BluetoothException(BluetoothException.ErrorCodes.TimedOut, "Timed out while waiting to enter connection phase. Another task is already preparing a connection.");
            }

            if (_client?.Connected ?? false)
            {
                Log.Debug("Windows.BluetoothService: Already connected, skipped.");
                _connSemaphore.Release();
                return;
            }

            SelectAdapter();

            Connecting?.Invoke(this, EventArgs.Empty);
            Log.Debug($"Windows.BluetoothService: Connecting...");

            _cancelSource?.Cancel();
            _client?.Close();
            _client = null;
            SelectAdapter();

            if (_client == null)
            {
                Log.Error("Windows.BluetoothService: Cannot create client and connect.");
                BluetoothErrorAsync?.Invoke(this, new BluetoothException(BluetoothException.ErrorCodes.Unknown, "Cannot create client"));
                _connSemaphore.Release();
                return;
            }

            try
            {
                try
                {
                    var addr = MacUtils.ToAddress(macAddress);
                    if (addr == null)
                    {
                        Log.Error("Windows.BluetoothService: Invalid MAC address. Failed to connect.");
                        throw new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed, "Invalid MAC address. Please deregister your device and try again.");
                    }

                    _currentMac  = macAddress;
                    _currentUuid = uuid;

                    _client.Connect(addr, new Guid(uuid));

                    /*await  Task.Factory.FromAsync(
                     *  (callback, stateObject) => _client.BeginConnect(addr, new Guid(uuid), callback, stateObject),
                     *  _client.EndConnect, null);*/
                }
                catch (ArgumentException)
                {
                    BluetoothErrorAsync?.Invoke(this, new BluetoothException(
                                                    BluetoothException.ErrorCodes.ConnectFailed,
                                                    $"Invalid MAC address. Please deregister your device and try again."));
                    _connSemaphore.Release();
                    return;
                }

                Connected?.Invoke(this, EventArgs.Empty);
                Log.Debug($"Windows.BluetoothService: Connected. Launching BluetoothServiceLoop.");

                _cancelSource = new CancellationTokenSource();
                _loop         = Task.Run(BluetoothServiceLoop, _cancelSource.Token);
            }
            catch (SocketException e)
            {
                BluetoothErrorAsync?.Invoke(this,
                                            new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed, e.Message));
            }
            finally
            {
                _connSemaphore.Release();
            }
        }
Ejemplo n.º 26
0
 // Each time you press a button move to the correct menu page
 void FixedUpdate()
 {
     // Called when you quit a game you're in
     if (Store.activeSelf && !_stop)
     {
         Lights.GetComponent <ParticleController>().Play();
         _stop = true;
     }
     // Called after log in
     if (!_started && GetComponent <Controller>().LoggedIn)
     {
         _started = true;
         Store.SetActive(true);
         Single.SetActive(true);
         Title.SetActive(true);
         Online.SetActive(true);
         Controls.SetActive(true);
     }
     // Called when you enter the store
     if (Store.GetComponent <ButtonController>().Pressed == true)
     {
         Store.transform.GetComponent <Renderer>().material = Materials[0];
         Store.GetComponent <ButtonController>().Pressed    = false;
         Store.SetActive(false);
         Single.SetActive(false);
         Title.SetActive(false);
         Online.SetActive(false);
         Controls.SetActive(false);
         Shop.SetActive(true);
         BackTL.SetActive(true);
         Transition(2);
     }
     // Called when you select the online button
     if (Online.GetComponent <ButtonController>().Pressed == true)
     {
         Online.transform.GetComponent <Renderer>().material = Materials[0];
         Host.transform.GetComponent <Renderer>().material   = Materials[0];
         Online.GetComponent <ButtonController>().Pressed    = false;
         Host.SetActive(true);
         Join.SetActive(true);
         Back.SetActive(true);
         Store.SetActive(false);
         Title.SetActive(false);
         Single.SetActive(false);
         Online.SetActive(false);
         Controls.SetActive(false);
         Transition(2);
     }
     // Called when you select the back button
     if (Back.GetComponent <ButtonController>().Pressed == true)
     {
         Back.transform.GetComponent <Renderer>().material = Materials[0];
         Back.GetComponent <ButtonController>().Pressed    = false;
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         Store.SetActive(true);
         Single.SetActive(true);
         Title.SetActive(true);
         Online.SetActive(true);
         Controls.SetActive(true);
         Transition(1);
     }
     // Called when you request to be a host
     if (Host.GetComponent <ButtonController>().Pressed == true)
     {
         Host.transform.GetComponent <Renderer>().material = Materials[0];
         Lights.GetComponent <ParticleController>().Stop();
         Host.GetComponent <ButtonController>().Pressed = false;
         // Respawns the networkcontroller on the server so you can pass messages to clients
         _networkManager.GetComponent <NetworkManager>().StartHost();
         NetworkServer.Spawn(NetworkController);
         foreach (GameObject g in GameModes)
         {
             GameObject mode = GameObject.Instantiate(g);
             NetworkServer.Spawn(mode);
         }
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         _stop = false;
     }
     // Called when you ask to join a game
     if (Join.GetComponent <ButtonController>().Pressed == true)
     {
         Join.transform.GetComponent <Renderer>().material = Materials[0];
         Lights.GetComponent <ParticleController>().Stop();
         _stop = false;
         _networkManager.GetComponent <NetworkManager>().StartClient();
         PTC.SetActive(true);
         Connecting.SetActive(true);
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         Join.GetComponent <ButtonController>().Pressed = false;
     }
     // Called when you ask to play a single player game
     if (Single.GetComponent <ButtonController>().Pressed == true)
     {
         Single.transform.GetComponent <Renderer>().material = Materials[0];
         Lights.GetComponent <ParticleController>().Stop();
         _stop = false;
         Single.GetComponent <ButtonController>().Pressed = false;
         SinglePlayer = true;
         Store.SetActive(false);
         Single.SetActive(false);
         Title.SetActive(false);
         Online.SetActive(false);
         Controls.SetActive(false);
         Transition(2);
     }
     // Called when you go to the controls menu
     if (Controls.GetComponent <ButtonController>().Pressed == true)
     {
         Controls.transform.GetComponent <Renderer>().material = Materials[0];
         Controls.GetComponent <ButtonController>().Pressed    = false;
         Controls.SetActive(false);
         Guide.SetActive(true);
         Store.SetActive(false);
         Single.SetActive(false);
         Title.SetActive(false);
         Online.SetActive(false);
         BackTL.SetActive(true);
         Transition(2);
     }
     // Called when you press the back button in the store or controls menu
     if (BackTL.GetComponent <ButtonController>().Pressed == true)
     {
         BackTL.GetComponent <ButtonController>().Pressed = false;
         BackTL.SetActive(false);
         Shop.SetActive(false);
         Guide.SetActive(false);
         Store.SetActive(true);
         Single.SetActive(true);
         Title.SetActive(true);
         Online.SetActive(true);
         Controls.SetActive(true);
         Transition(1);
     }
     // If you're trying to join a server but cancel
     if (Input.GetKeyDown(KeyCode.Escape) && Connecting.activeSelf)
     {
         _networkManager.GetComponent <NetworkManager>().StopClient();
         PTC.SetActive(false);
         Connecting.SetActive(false);
         Transition(1);
     }
     // When you actually connecct to the server hide all the extra buttons
     if (NetworkController.GetComponent <NetworkController>().Server || NetworkController.GetComponent <NetworkController>().Client)
     {
         Host.SetActive(false);
         Join.SetActive(false);
         Back.SetActive(false);
         PTC.SetActive(false);
         Connecting.SetActive(false);
     }
 }
Ejemplo n.º 27
0
        public async Task ConnectAsync(string macAddress, string serviceUuid, bool noRetry = false)
        {
            if (IsConnecting)
            {
                Log.Debug($"WindowsRT.BluetoothService: Already connecting. Skipping request.");
                return;
            }
            if (IsStreamConnected)
            {
                Log.Debug($"WindowsRT.BluetoothService: Already connected. Skipping request.");
                return;
            }

            Connecting?.Invoke(this, EventArgs.Empty);

            try
            {
                var matches = _deviceCache.Where(x =>
                                                 string.Equals(x.Address, macAddress, StringComparison.CurrentCultureIgnoreCase)).ToList();
                if (matches.Count <= 0)
                {
                    Log.Error(
                        $"WindowsRT.BluetoothService: Registered device not available. Expected MAC: {macAddress}");
                    BluetoothErrorAsync?.Invoke(this, new BluetoothException(
                                                    BluetoothException.ErrorCodes.ConnectFailed,
                                                    "Device unavailable. Not device with registered MAC address not found nearby. If you are certain that your earbuds are connected to this computer, please unregister them and try again."));
                }
                else
                {
                    Log.Debug(
                        $"WindowsRT.BluetoothService: Selected '{matches[0].Name}' ({matches[0].Address}) from cache as target");
                }

                // Perform device access checks before trying to get the device.
                // First, we check if consent has been explicitly denied by the user.
                var accessStatus = DeviceAccessInformation.CreateFromId(matches[0].Id).CurrentStatus;
                if (accessStatus == DeviceAccessStatus.DeniedByUser)
                {
                    Log.Error($"WindowsRT.BluetoothService: Access to device explicitly denied by user");
                    BluetoothErrorAsync?.Invoke(this,
                                                new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                       "This app does not have access to connect to the remote device (please grant access in Settings > Privacy > Other Devices"));
                    return;
                }

                if (accessStatus == DeviceAccessStatus.DeniedBySystem)
                {
                    Log.Error($"WindowsRT.BluetoothService: Access to device denied by system");
                    BluetoothErrorAsync?.Invoke(this,
                                                new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                       "Access denied by system. This app does not have access to connect to the remote device"));
                    return;
                }

                // If not, try to get the Bluetooth device
                try
                {
                    _bluetoothDevice = await Windows.Devices.Bluetooth.BluetoothDevice.FromIdAsync(matches[0].Id);
                }
                catch (Exception ex)
                {
                    Log.Error(
                        $"WindowsRT.BluetoothService: Error while getting Bluetooth device from cached id: {ex.Message}");
                    BluetoothErrorAsync?.Invoke(this,
                                                new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                       ex.Message));
                    return;
                }

                // If we were unable to get a valid Bluetooth device object,
                // it's most likely because the user has specified that all unpaired devices
                // should not be interacted with.
                if (_bluetoothDevice == null)
                {
                    Log.Error($"WindowsRT.BluetoothService: BluetoothDevice.FromIdAsync returned NULL");
                    BluetoothErrorAsync?.Invoke(this,
                                                new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                       "Unable to retrieve device object. Try to re-pair your Bluetooth device."));
                    return;
                }

                // This should return a list of uncached Bluetooth services (so if the server was not active when paired, it will still be detected by this call
                var rfcommServices = await _bluetoothDevice.GetRfcommServicesForIdAsync(
                    RfcommServiceId.FromUuid(new Guid(serviceUuid)), BluetoothCacheMode.Uncached);

                if (rfcommServices.Services.Count > 0)
                {
                    _service = rfcommServices.Services[0];
                }
                else
                {
                    Log.Error($"WindowsRT.BluetoothService: SPP service not discovered");
                    BluetoothErrorAsync?.Invoke(this,
                                                new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                       "Unable to discover SDP record for the RFCOMM protocol. Either your earbuds are out of range or ran out of battery."));
                    return;
                }

                lock (this)
                {
                    _socket = new StreamSocket();
                }

                try
                {
                    await _socket.ConnectAsync(_service.ConnectionHostName, _service.ConnectionServiceName);

                    Connected?.Invoke(this, EventArgs.Empty);
                    Log.Debug($"WindowsRT.BluetoothService: Connected");

                    _writer = new DataWriter(_socket.OutputStream);

                    Log.Debug("WindowsRT.BluetoothService: Launching BluetoothServiceLoop...");
                    RfcommConnected?.Invoke(this, EventArgs.Empty);

                    IsStreamConnected = true;

                    _loopCancellation = new CancellationTokenSource();
                    _loop             = Task.Run(BluetoothServiceLoop);
                }
                catch (Exception ex) when((uint)ex.HResult == 0x80070490)   // ERROR_ELEMENT_NOT_FOUND
                {
                    Log.Error(
                        "WindowsRT.BluetoothService: Error while connecting (HRESULT: ERROR_ELEMENT_NOT_FOUND): " +
                        ex.Message);
                    BluetoothErrorAsync?.Invoke(this,
                                                new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                       "SPP server on remote device unavailable. Please reboot your earbuds by placing both into the case and closing it. (ERROR_ELEMENT_NOT_FOUND)"));
                }
                catch (Exception ex) when((uint)ex.HResult == 0x80072740)   // WSAEADDRINUSE
                {
                    Log.Error("WindowsRT.BluetoothService: Address already in use");
                    BluetoothErrorAsync?.Invoke(this,
                                                new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                       "Target address already in use. Only one app can talk to the Galaxy Buds at a time. " +
                                                                       "Please make sure to close duplicate instances of this app and close all applications that are interacting with the proprietary RFCOMM protocol, such as Samsung's official firmware updater"));
                }
            }
            catch (Exception ex)
            {
                Log.Error("WindowsRT.BluetoothService: Unknown error while connecting: " + ex);
                BluetoothErrorAsync?.Invoke(this,
                                            new BluetoothException(BluetoothException.ErrorCodes.ConnectFailed,
                                                                   ex.Message));
            }
        }
Ejemplo n.º 28
0
 private void OnConnecting(ITcpClient tcpClient) => Connecting?.Invoke(this, new TcpIpClientConnect12EventArgs(tcpClient));