Inheritance: MonoBehaviour
Exemplo n.º 1
0
 private void SendKeepAlives()
 {
     new Thread(() =>
     {
         while (true)
         {
             try
             {
                 foreach (Client client in Clients)
                 {
                     KeepAlive keepAlive = new KeepAlive();
                     lock (_keepAlives)
                     {
                         _keepAlives.Add(keepAlive);
                     }
                     keepAlive.Execute(client);
                     Timer timer = new Timer(KeepAliveCallback, keepAlive, 10000, Timeout.Infinite);
                 }
             }
             catch
             {
             }
             Thread.Sleep(10000);
         }
     })
     {
         IsBackground = true
     }.Start();
 }
Exemplo n.º 2
0
        public void MergeFrom(BehaviorControlResponse other)
        {
            if (other == null)
            {
                return;
            }
            switch (other.ResponseTypeCase)
            {
            case ResponseTypeOneofCase.ControlGrantedResponse:
                if (ControlGrantedResponse == null)
                {
                    ControlGrantedResponse = new global::Anki.Vector.ExternalInterface.ControlGrantedResponse();
                }
                ControlGrantedResponse.MergeFrom(other.ControlGrantedResponse);
                break;

            case ResponseTypeOneofCase.ControlLostEvent:
                if (ControlLostEvent == null)
                {
                    ControlLostEvent = new global::Anki.Vector.ExternalInterface.ControlLostResponse();
                }
                ControlLostEvent.MergeFrom(other.ControlLostEvent);
                break;

            case ResponseTypeOneofCase.KeepAlive:
                if (KeepAlive == null)
                {
                    KeepAlive = new global::Anki.Vector.ExternalInterface.KeepAlivePing();
                }
                KeepAlive.MergeFrom(other.KeepAlive);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Exemplo n.º 3
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            KeepAlive keepAlive = new KeepAlive();

            sendData("KeepAlive", keepAlive);
            ServerLog.writeLog("Ping..{0}" + ID);
        }
Exemplo n.º 4
0
        public async Task Does_Not_Execute_When_Not_Enabled()
        {
            KeepAlive sut = CreateKeepAlive(enabled: false);
            await sut.PerformExecuteAsync(null);

            VerifyKeepAliveRequestNotSent();
        }
 private void Timer_KeepAlive(object sender, ElapsedEventArgs e)
 {
     if (IsConnected)
     {
         KeepAlive?.Invoke(this);
     }
 }
Exemplo n.º 6
0
        public async Task Does_Not_Execute_When_Server_Role_Is_Unknown()
        {
            KeepAlive sut = CreateKeepAlive(serverRole: ServerRole.Unknown);
            await sut.PerformExecuteAsync(null);

            VerifyKeepAliveRequestNotSent();
        }
Exemplo n.º 7
0
        public async Task Does_Not_Execute_When_Not_Main_Dom()
        {
            KeepAlive sut = CreateKeepAlive(isMainDom: false);
            await sut.PerformExecuteAsync(null);

            VerifyKeepAliveRequestNotSent();
        }
Exemplo n.º 8
0
 public HomeController(DBContext db, KeepAlive ka, Cryptography c, GitHub git)
 {
     _db        = db ?? throw new ArgumentNullException(nameof(db));
     _c         = c ?? throw new ArgumentNullException(nameof(c));
     _git       = git ?? throw new ArgumentNullException(nameof(git));
     _keepalive = ka ?? throw new ArgumentNullException(nameof(ka));
 }
Exemplo n.º 9
0
        /// <summary>
        /// Connects to the Myos and register the neded handlers.
        /// </summary>
        private static void ConnectToMyos()
        {
            var channel = (Channel)CreateChannel();

            using (var hub = Hub.Create(channel))
            {
                // listen for when the Myo connects
                hub.MyoConnected += (sender, e) =>
                {
                    HandleMyoConnected(e);
                };

                // listen for when the Myo disconnects
                hub.MyoDisconnected += (sender, e) =>
                {
                    _logger.Info($"Oh no! It looks like {e.Myo.Arm} arm Myo has disconnected!");
                };

                // start listening for Myo data
                channel.StartListening();

                // wait on user input
                KeepAlive.UserInputLoop(hub);
            }
        }
Exemplo n.º 10
0
        public async Task Executes_And_Calls_Ping_Url()
        {
            KeepAlive sut = CreateKeepAlive();
            await sut.PerformExecuteAsync(null);

            VerifyKeepAliveRequestSent();
        }
Exemplo n.º 11
0
        internal Connections()
        {
            _connections = new ArrayList();
            _activeIndex = -1;
            _keepAlive   = new KeepAlive();

            _activatedOrder = new ArrayList();
        }
Exemplo n.º 12
0
        protected void SendKeepAlive()
        {
            KeepAlive ka = new KeepAlive();

            ka.DestinationID = session.Destination.SocketID;
            ka.SetSession(session);
            endpoint.DoSend(ka);
        }
Exemplo n.º 13
0
    protected override void Awake()
    {
        base.Awake();

        KeepAlive.Apply(this);

        //StartCoroutine(CleanupLoop());
    }
Exemplo n.º 14
0
        //send single keep alive packet -> move to socket!
        protected void SendKeepAlive()
        {
            KeepAlive keepAlive = new KeepAlive();

            //TODO
            keepAlive.SetSession(session);
            endpoint.DoSend(keepAlive);
        }
Exemplo n.º 15
0
    protected override void Awake()
    {
        base.Awake();

        KeepAlive.Apply(this);

        CleanupHook.CreateSingleton();
        FPSCounter.CreateSingleton();
    }
Exemplo n.º 16
0
        public void Handle(KeepAlive message)
        {
            Log.Debug("Keep alive received");

            if (ClientCallback != null)
            {
                ClientCallback.HandleKeepAlive();
            }
        }
Exemplo n.º 17
0
            public DefaultRequestDispatcher(ConnectionHost connectionHost, CompilerHost compilerHost, CancellationToken cancellationToken)
            {
                _connectionHost    = connectionHost;
                _compilerHost      = compilerHost;
                _cancellationToken = cancellationToken;

                _eventBus  = EventBus.Default;
                _keepAlive = new KeepAlive(DefaultServerKeepAlive, isDefault: true);
            }
Exemplo n.º 18
0
        public override void Update()
        {
            base.Update();

            if (Connected)
            {
                KeepAlive.KeepAlive(Connection);
            }
        }
Exemplo n.º 19
0
 public static Offset <KeepAlive> CreateKeepAlive(FlatBufferBuilder builder,
                                                  short opcode = 2,
                                                  bool success = false)
 {
     builder.StartTable(2);
     KeepAlive.AddOpcode(builder, opcode);
     KeepAlive.AddSuccess(builder, success);
     return(KeepAlive.EndKeepAlive(builder));
 }
 /// <summary>
 /// Disconnect the client connection.
 /// </summary>
 public void Disconnect()
 {
     if (Session != null)
     {
         KeepAlive?.Invoke(Session, null);
         Session.Close();
         Session = null;
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// 初始化
 /// </summary>
 internal void Initialize(SocketDispatcherBase socketDispatcher,
                          InternalSendDataEventHandler internalSendDataEventHandler,
                          Func <SocketAsyncEventArgs, bool> saeaCollectEventHandler)
 {
     _keepAlive             = new KeepAlive();
     this._socketDispatcher = socketDispatcher;
     this._sendData         = internalSendDataEventHandler;
     readBuffer.Initialize(saeaCollectEventHandler, this);
     OnInitialized();
 }
Exemplo n.º 22
0
        private void KeepAliveCallback(object state)
        {
            KeepAlive keepAlive = (KeepAlive)state;

            if (_keepAlives.Contains(keepAlive))
            {
                keepAlive.Client.Disconnect();
                _keepAlives.Remove(keepAlive);
            }
        }
 /// <summary>
 /// Disconnects this instance.
 /// </summary>
 public void Disconnect()
 {
     if (m_session != null)
     {
         KeepAlive?.Invoke(m_session, null);
         m_session.Close();
         m_session = null;
         RaiseConnectionStatusChangedEvent();
     }
 }
Exemplo n.º 24
0
 // Start is called before the first frame update
 void Start()
 {
     if (Instance != null)
     {
         DestroyImmediate(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
     Instance = this;
 }
        /// <summary>
        /// sip请求消息
        /// </summary>
        /// <param name="localSIPEndPoint">本地终结点</param>
        /// <param name="remoteEndPoint">远程终结点</param>
        /// <param name="request">sip请求</param>
        public void AddMessageRequest(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint, SIPRequest request)
        {
            //注册请求
            if (request.Method == SIPMethodsEnum.REGISTER)
            {
                m_registrarCore.AddRegisterRequest(localSIPEndPoint, remoteEndPoint, request);
            }
            //消息请求
            else if (request.Method == SIPMethodsEnum.MESSAGE)
            {
                KeepAlive keepAlive = KeepAlive.Instance.Read(request.Body);
                if (keepAlive != null)  //心跳
                {
                    if (!_initSIP)
                    {
                        LocalEndPoint  = request.Header.To.ToURI.ToSIPEndPoint();
                        RemoteEndPoint = request.Header.From.FromURI.ToSIPEndPoint();
                        LocalSIPId     = request.Header.To.ToURI.User;
                        RemoteSIPId    = request.Header.From.FromURI.User;
                    }

                    _initSIP = true;

                    OnSIPServiceChange(RemoteSIPId, SipServiceStatus.Complete);
                }
                else   //目录检索
                {
                    Catalog catalog = Catalog.Instance.Read(request.Body);
                    if (catalog != null)
                    {
                        foreach (var cata in catalog.DeviceList.Items)
                        {
                            lock (MonitorService)
                            {
                                if (!MonitorService.ContainsKey(cata.DeviceID))
                                {
                                    ISIPMonitorService monitor = new SIPMonitorCore(this, cata.DeviceID, cata.Name);
                                    monitor.OnSIPServiceChanged += monitor_OnSIPServiceChanged;
                                    MonitorService.Add(cata.DeviceID, monitor);
                                }
                            }
                        }
                        OnCatalogReceive(catalog);
                    }
                }
                SIPResponse msgRes = GetResponse(localSIPEndPoint, remoteEndPoint, SIPResponseStatusCodesEnum.Ok, "", request);
                Transport.SendResponse(msgRes);
            }
            //停止播放请求
            else if (request.Method == SIPMethodsEnum.BYE)
            {
                SIPResponse byeRes = GetResponse(localSIPEndPoint, remoteEndPoint, SIPResponseStatusCodesEnum.Ok, "", request);
                Transport.SendResponse(byeRes);
            }
        }
Exemplo n.º 26
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
            KeepAlive.StartThread();
        }
Exemplo n.º 27
0
 public static void Reconnect()
 {
     try
     {
         Ping?.Dispose();
         KeepAlive?.Dispose();
         SslClient?.Dispose();
         TcpClient?.Dispose();
     }
     catch { }
 }
Exemplo n.º 28
0
        internal void OnKeepaliveReceived(SIPEndPoint remoteEP, KeepAlive keapalive, string devId)
        {
            _keepaliveTime = DateTime.Now;
            var hbPoint = new HeartBeatEndPoint()
            {
                RemoteEP = remoteEP,
                Heart    = keapalive
            };

            _keepAliveQueue.Enqueue(hbPoint);
        }
Exemplo n.º 29
0
 internal HttpStream(Uri uri, HttpSettings settings) : base(null)
 {
     this.baseUrl                  = string.Concat(uri.Scheme, Uri.SchemeDelimiter, uri.Authority);
     this.keepAlive                = new KeepAlive(DateTime.Now + settings.keepAliveTimeout);
     this.uri                      = uri;
     this.tcpClient                = new TcpClient();
     this.sslVerifier              = settings.sslVerifier;
     this.tcpClient.NoDelay        = settings.tcpNoDelay;
     this.tcpClient.SendTimeout    = (int)settings.tcpSendTimeout.TotalMilliseconds;
     this.tcpClient.ReceiveTimeout = (int)settings.tcpReceiveTimeout.TotalMilliseconds;
 }
Exemplo n.º 30
0
        void MessageCore_OnKeepaliveReceived(SIPEndPoint remoteEP, KeepAlive keapalive, string devId)
        {
            _keepaliveTime = DateTime.Now;
            Keep keep = new Keep()
            {
                RemoteEP = remoteEP,
                Heart    = keapalive
            };

            _keepQueue.Enqueue(keep);
        }
Exemplo n.º 31
0
 internal void Handle(KeepAlive input) {
    Reply(true);
 }
Exemplo n.º 32
0
 private void EstablishConnection(bool tagged, KeepAlive keepAlive)
 {
     if (m_ClientApi != null && m_ClientApi.Dropped() != 0)
     {
         // I can't figure out how to force this artificially, so currently untested :-(
         CloseConnection();
     }
     if (m_ClientApi == null)
     {
         m_ClientApi = new ClientApi();
     }
     if (!_Initialized)
     {
         Error err = null;
         try
         {
             _tagged = tagged;
             err = m_ClientApi.CreateError();
            
             // Always use the specstring protocol.  We'll controll form output via SetTag
             // before each run
             m_ClientApi.SetProtocol("specstring", "");                    
             
             //May have lost our settings... reset here
             if (_Client != null) m_ClientApi.SetClient(_Client);
             if (_User != null) m_ClientApi.SetUser(_User);
             if (_CWD != null) m_ClientApi.SetCwd(_CWD);
             if (_Charset != null) m_ClientApi.SetCharset(_Charset);
             if (_Host != null) m_ClientApi.SetHost(_Host); 
             if (_Port != null) m_ClientApi.SetPort(_Port);
             if (_Password != null) m_ClientApi.SetPassword(_Password);
             if (_TicketFile != null) m_ClientApi.SetTicketFile(_TicketFile);
             if (_maxResults != 0) m_ClientApi.SetMaxResults(_maxResults);
             if (_maxScanRows != 0) m_ClientApi.SetMaxScanRows(_maxResults);
             if (_maxLockTime != 0) m_ClientApi.SetMaxLockTime(_maxLockTime);
             if (_ApiLevel != 0) m_ClientApi.SetProtocol("api", _ApiLevel.ToString());
             
             m_ClientApi.Init(err);
             if (err.Severity == Error.ErrorSeverity.Failed || err.Severity == Error.ErrorSeverity.Fatal)
             {
                 throw new Exception("Unable to connect to Perforce!");
             }
             _Initialized = true;
             err.Dispose();
         }
         catch (Exception e)
         {
             string message = "Perforce connection error.";
             try
             {
                 m_ClientApi.Final(err);
                 message = e.Message;
                 err.Dispose();
                 m_ClientApi.Dispose();
                 m_ClientApi = null;
             }
             catch { }
             throw new PerforceInitializationError(message);
         }
     }
     if (tagged) m_ClientApi.SetTag();
     if (_CallingProgram != null) m_ClientApi.SetProg(_CallingProgram);
     if (_CallingProgramVersion != null) m_ClientApi.SetVersion(_CallingProgramVersion);
     m_ClientApi.SetBreak(keepAlive);
 }
Exemplo n.º 33
0
    public bool Update()
    {
        bool bRet = true;

        float fRealtimeSinceStartup = Time.time;
        float fRealDeltaTime = (m_fLastRealtimeSinceStartup == 0) ? 0 : fRealtimeSinceStartup - m_fLastRealtimeSinceStartup;


        // --------------------------------------
        // connection check
        if (m_bLastIsConnected && !IsConnected)
        {
        }

        if (IsLinkBroken)
            LinkBroken(true);

        if (LinkBrokenEvent != 0)
        {
            int nEvent = LinkBrokenEvent;
            LinkBrokenEvent = 0;

            if (wLua.L != null && wLua.L.L != null)
            {
                LuaDLL.lua_getglobal(wLua.L.L, "OnDisConnect");
                LuaDLL.lua_pushnumber(wLua.L.L, nEvent);
                wLua.L.Call(1);
            }
        }

        // --------------------------------------
        // overtime check
        if (Overtime.Check)
        {
            Overtime.LifeTime += fRealDeltaTime;
            if (Overtime.LifeTime >= Overtime.TTL)
            {
                Overtime.Check = false;
                OnOvertimeHappen();
            }
        }

        // --------------------------------------
        // keep alive
        if (IsConnected)
        {
            m_fElapsedTime += fRealDeltaTime;
            if (m_fElapsedTime > 30)
            {
                m_fElapsedTime = 0;
				uint t = (uint)Environment.TickCount;
                if (gamesession.NetMan.LastSendAlive != 0 && (gamesession.NetMan.LastSendAlive > gamesession.NetMan.LastRecvAlive))
				{
					IsLinkBroken = true;
					LinkBroken(true);
				}
 				else
 				{
					KeepAlive p = new KeepAlive(); 
					KeepAlive.Lastsend = fRealtimeSinceStartup;
					gamesession.NetMan.LastSendAlive = t;
					gamesession.SendNetData(p);
				}
            }

        }

        m_bLastIsConnected = IsConnected;
        m_fLastRealtimeSinceStartup = fRealtimeSinceStartup;

        return bRet;
    }
Exemplo n.º 34
0
 public void CastSpellAtIndex(int spellIndex, KeepAlive spellKeepAlive)
 {
     var sp = _playerCharacter.GetSpellAtIndex(spellIndex);
     if (sp != null)
     {
         CastSpellAtIndex(sp, spellKeepAlive);
     }
 }
Exemplo n.º 35
0
    /// <summary>
    /// Handles casting the specified spell. It will ensure the player Entity casts the spell with the mouse coordinate passed in 
    /// as arguments. It will also ensure the player looks at the mouse and stops moving.
    /// </summary>
    /// <param name="spell"></param>
    public void CastSpellAtIndex(Spell spell, KeepAlive spellKeepAlive)
    {
        if (spell == null)
            return;

        CastSlowness = true;
        Spell castSpell;
        // Ignore spell cost is spell equals the costume's base spell.
        if (Entity.CastSpell(spell, out castSpell, null, GetMouseWorldPoint(), false))
        {
            if (castSpell != null)
                castSpell.KeepAliveDelegate = spellKeepAlive;
        }
        else if (!Entity.HasElementalChargeToCast(spell) && _displayStatusTextTimer.CanTickAndReset())
        {
            // Check what element is not sufficiant
            foreach (Element elem in Enum.GetValues(typeof(Element)))
            {
                if(Entity.CurrentElementalCharge[elem] < spell.ElementalCost[elem])
                {
                    var s = StatusTextPool.Instance.GetObjectFromPool((e) =>
                    {
                        e.TextColor = _elementTextColorsDict[elem];
                        e.Target = Entity.GUIHealthPoint.transform;
                        e.StatusText = string.Format("Not Enough {0}!", elem);
                    });
                    s.gameObject.SetActive(true);
                    // Only display one text status at the time.
                    // In this case may as well just get the first element that we need charge for.
                    return;
                }
            }

        }
    }