Ejemplo n.º 1
0
        private void Tick()
        {
            if (!_client.IsConnected)
            {
                return;
            }

            _currentTimeInMilliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            if (_currentTimeInMilliseconds - _lastKeepAlive > INTERVAL_KeepAlive)
            {
                UsCmd cmd = new UsCmd();
                cmd.WriteNetCmd(eNetCmd.CL_KeepAlive);
                _client.SendPacket(cmd);
                _lastKeepAlive = _currentTimeInMilliseconds;
            }

            if (_currentTimeInMilliseconds - _lastCheckingConnectionStatus > INTERVAL_CheckingConnectionStatus)
            {
                _client.Tick_CheckConnectionStatus();
                _lastCheckingConnectionStatus = _currentTimeInMilliseconds;
            }

            if (_currentTimeInMilliseconds - _lastReceivingData > INTERVAL_ReceivingData)
            {
                _client.Tick_ReceivingData();
                _lastReceivingData = _currentTimeInMilliseconds;
            }
        }
Ejemplo n.º 2
0
        private bool NetHandle_KeepAlive(eNetCmd cmd, UsCmd c)
        {
            UsCmd reply = new UsCmd();

            reply.WriteNetCmd(eNetCmd.SV_KeepAliveResponse);
            UsNet.Instance.SendCommand(reply);
            return(true);
        }
Ejemplo n.º 3
0
        private bool NetHandle_Handshake(eNetCmd cmd, UsCmd c)
        {
            Debug.Log("executing handshake.");
            UsCmd reply = new UsCmd();

            reply.WriteNetCmd(eNetCmd.SV_HandshakeResponse);
            UsNet.Instance.SendCommand(reply);
            return(true);
        }
Ejemplo n.º 4
0
        public UsCmd CreatePacket()
        {
            UsCmd c = new UsCmd();

            c.WriteNetCmd(eNetCmd.SV_App_Logging);
            c.WriteInt16((short)SeqID);
            c.WriteInt32((int)LogType);
            c.WriteStringStripped(Content, MAX_CONTENT_LEN);
            c.WriteFloat(RealtimeSinceStartup);
            return(c);
        }
Ejemplo n.º 5
0
        public void ExecuteCmd(string cmdText)
        {
            if (!IsConnected)
            {
                NetUtil.Log("not connected to server, command ignored.");
                return;
            }

            if (cmdText.Length == 0)
            {
                NetUtil.Log("the command bar is empty, try 'help' to list all supported commands.");
                return;
            }

            UsCmd cmd = new UsCmd();

            cmd.WriteNetCmd(eNetCmd.CL_ExecCommand);
            cmd.WriteString(cmdText);
            Send(cmd);

            NetUtil.Log("command executed: [b]{0}[/b]", cmdText);
        }
Ejemplo n.º 6
0
        private void writeNetCmd(UsCmd uscmd)
        {
            uscmd.ClearCmd();
            uscmd.WriteNetCmd(eNetCmd.SV_VarTracerInfo);
            //group count
            uscmd.WriteInt32(_cmdCacher.GetUsedGroupCount());
            foreach (var package in _cmdCacher.GroupCmdPackage)
            {
                if (package.Value.IsUse())
                {
                    //group name
                    uscmd.WriteString(package.Key);

                    //variable count
                    uscmd.WriteInt32(_cmdCacher.GetUsedVariableCount(package.Value));
                    foreach (var list in package.Value.VariableDict)
                    {
                        if (list.Value.IsUse())
                        {
                            //variable name
                            uscmd.WriteString(list.Key);
                            //session count
                            uscmd.WriteInt32(list.Value.UseIndex);
                            var cacheList = list.Value;
                            int usedCount = cacheList.UseIndex;
                            for (int i = 0; i < usedCount; i++)
                            {
                                //UnityEngine.Debug.LogFormat("send stamp= {0}", list.Value.VarChacheList[i]._stamp);
                                //stamp
                                uscmd.WriteLong(list.Value.VarChacheList[i]._stamp);
                                //value
                                uscmd.WriteFloat(list.Value.VarChacheList[i]._value);
                            }
                        }
                    }

                    //event count
                    uscmd.WriteInt32(_cmdCacher.GetUsedEventCount(package.Value));
                    foreach (var list in package.Value.EventDict)
                    {
                        if (list.Value.IsUse())
                        {
                            //event name
                            uscmd.WriteString(list.Key);
                            //session count
                            uscmd.WriteInt32(list.Value.UseIndex);
                            var cacheList = list.Value;
                            int usedCount = cacheList.UseIndex;
                            for (int i = 0; i < usedCount; i++)
                            {
                                //stamp
                                uscmd.WriteLong(list.Value.VarChacheList[i]._stamp);
                                //duration
                                uscmd.WriteFloat(list.Value.VarChacheList[i]._duration);
                            }
                        }
                    }
                }
            }

            UsNet.Instance.SendCommand(uscmd);
        }