Beispiel #1
0
        public bool NetHandle_Editor_SelectionChanged(eNetCmd cmd, UsCmd c)
        {
            int count = c.ReadInt32();
            UsLogging.Printf("eNetCmd.SV_Editor_SelectionChanged received ({0}, inst count: {1}).", c.Buffer.Length, count);

            _instances.Clear();
            for (int i = 0; i < count; i++)
            {
                int instID = c.ReadInt32();
                _instances.Add(instID);
            }

            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                ClearAllSelectionsAndHighlightedObjects();
                var meshes = HighlightMeshes(_instances, Colors.PaleTurquoise);
                foreach (var mesh in meshes)
                {
                    var matLst = HighlightMaterialByMesh(mesh, Colors.PaleTurquoise);
                    foreach (var mat in matLst)
                        HighlightTextureByMaterial(mat, Colors.PaleTurquoise);
                }
            }));

            return true;
        }
Beispiel #2
0
        private bool Handle_ServerLogging(eNetCmd cmd, UsCmd c)
        {
            UsLogPacket pkt = new UsLogPacket(c);

            UsNetLogging.Print(pkt);
            return(true);
        }
Beispiel #3
0
    private bool NetHandle_ExecCommand(string clientID, eNetCmd cmd, UsCmd c)
    {
        string str = c.ReadString();

        string[] args = str.Split((char[])Array.Empty <char>());
        if (args.Length == 0)
        {
            Log.Info((object)"empty command received, ignored.", (object[])Array.Empty <object>());
            return(false);
        }
        UsvClientConsoleCmdHandler consoleCmdHandler;

        if (!this._clientConsoleCmdHandlers.TryGetValue(args[0].ToLower(), out consoleCmdHandler))
        {
            Log.Info((object)"unknown command ('{0}') received, ignored.", (object)str);
            return(false);
        }
        bool  flag = consoleCmdHandler(clientID, args);
        UsCmd cmd1 = new UsCmd();

        cmd1.WriteNetCmd(eNetCmd.SV_ExecCommandResponse);
        cmd1.WriteInt32(!flag ? 0 : 1);
        this.SendCommand(clientID, cmd1);
        return(true);
    }
    private bool NetHandle_ExecCommand(string clientID, eNetCmd cmd, UsCmd c)
    {
        string read = c.ReadString();

        string[] fragments = read.Split();
        if (fragments.Length == 0)
        {
            Log.Info("empty command received, ignored.");
            return(false);
        }

        UsvClientConsoleCmdHandler handler;

        if (!_clientConsoleCmdHandlers.TryGetValue(fragments[0].ToLower(), out handler))
        {
            Log.Info("unknown command ('{0}') received, ignored.", read);
            return(false);
        }

        bool succ = handler(clientID, fragments);

        UsCmd reply = new UsCmd();

        reply.WriteNetCmd(eNetCmd.SV_ExecCommandResponse);
        reply.WriteInt32(succ ? 1 : 0);
        SendCommand(clientID, reply);
        return(true);
    }
Beispiel #5
0
        public UsCmdExecResult ExecuteClient(string clientID, UsCmd c)
        {
            try
            {
                eNetCmd            cmd = c.ReadNetCmd();
                UsClientCmdHandler handler;
                if (!m_clientHandlers.TryGetValue(cmd, out handler))
                {
                    return(UsCmdExecResult.HandlerNotFound);
                }

                if (handler(clientID, cmd, c))
                {
                    return(UsCmdExecResult.Succ);
                }
                else
                {
                    return(UsCmdExecResult.Failed);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("[cmd] Execution failed. ({0})", ex.Message);
                return(UsCmdExecResult.Failed);
            }
        }
Beispiel #6
0
    public static bool Handle_ServerLogging(eNetCmd cmd, UsCmd c)
    {
        UsLogPacket pkt = new UsLogPacket(c);

        string logTypeStr = "";

        switch (pkt.LogType)
        {
        case UsLogType.Error:
        case UsLogType.Exception:
        case UsLogType.Assert:
        case UsLogType.Warning:
            logTypeStr = string.Format("{1}", pkt.LogType);
            break;

        case UsLogType.Log:
        default:
            break;
        }

        string timeStr = string.Format("{0:0.00}({1})", pkt.RealtimeSinceStartup, pkt.SeqID);

        string ret = string.Format("{0} {1} <color=white>{2}</color>", timeStr, logTypeStr, pkt.Content);

        if (!string.IsNullOrEmpty(pkt.Callstack))
        {
            ret += string.Format("\n<color=gray>{0}</color>", pkt.Callstack);
        }

        Debug.Log(ret);

        return(true);
    }
Beispiel #7
0
        private bool NetHandle_Editor_SelectionChanged(eNetCmd cmd, UsCmd c)
        {
            int count = c.ReadInt32();

            UsLogging.Printf("eNetCmd.SV_Editor_SelectionChanged received ({0}, inst count: {1}).", c.Buffer.Length, count);

            _instances.Clear();
            for (int i = 0; i < count; i++)
            {
                int instID = c.ReadInt32();
                _instances.Add(instID);
            }

            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                ClearAllSelectionsAndHighlightedObjects();
                var meshes = HighlightMeshes(_instances, Colors.PaleTurquoise);
                foreach (var mesh in meshes)
                {
                    var matLst = HighlightMaterialByMesh(mesh, Colors.PaleTurquoise);
                    foreach (var mat in matLst)
                    {
                        HighlightTextureByMaterial(mat, Colors.PaleTurquoise);
                    }
                }
            }));

            return(true);
        }
Beispiel #8
0
        public bool NetHandle_FrameData_Material(eNetCmd cmd, UsCmd c)
        {
            UsLogging.Printf("eNetCmd.Handle_FrameData_Material received ({0}).", c.Buffer.Length);

            var materials = new ObservableCollection <MaterialObject>();
            int count     = c.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var m = new MaterialObject();
                m.InstID     = c.ReadInt32();
                m.Name       = c.ReadString();
                m.ShaderName = c.ReadString();
                m.RefCnt     = c.ReadInt32();

                m.RefList = new List <int>();
                for (int k = 0; k < m.RefCnt; k++)
                {
                    int owner = c.ReadInt32();
                    m.RefList.Add(owner);
                }

                materials.Add(m);
            }

            MaterialGrid.Dispatcher.Invoke(new Action(() =>
            {
                title_material.Text      = string.Format("Materials ({0})", materials.Count);
                MaterialGrid.DataContext = materials;
            }));
            return(true);
        }
Beispiel #9
0
        public bool NetHandle_FrameDataV2_Names(eNetCmd cmd, UsCmd c)
        {
            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                int count = c.ReadInt32();
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2_Names [b]({0} got)[/b].", count);
                for (int i = 0; i < count; i++)
                {
                    int instID      = c.ReadInt32();
                    string instName = c.ReadString();
                    foreach (var item in MeshGrid.Items)
                    {
                        MeshObject mo = item as MeshObject;
                        if (mo != null && mo.InstID == instID)
                        {
                            mo.Name = instName;
                        }
                    }
                }

                MeshGrid.Items.Refresh();
            }));

            return(true);
        }
Beispiel #10
0
        public bool NetHandle_FrameData_Texture(eNetCmd cmd, UsCmd c)
        {
            UsLogging.Printf("eNetCmd.Handle_FrameData_Texture received ({0}).", c.Buffer.Length);

            var textures = new ObservableCollection <TextureObject>();
            int count    = c.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var m = new TextureObject();
                m.InstID    = c.ReadInt32();
                m.Name      = c.ReadString();
                m.PixelSize = c.ReadString();
                m.MemSize   = c.ReadString();
                m.RefCnt    = c.ReadInt32();
                m.RefList   = new List <int>();
                for (int k = 0; k < m.RefCnt; k++)
                {
                    int owner = c.ReadInt32();
                    m.RefList.Add(owner);
                }

                textures.Add(m);
            }

            TextureGrid.Dispatcher.Invoke(new Action(() =>
            {
                title_texture.Text      = string.Format("Textures ({0})", textures.Count);
                TextureGrid.DataContext = textures;
            }));
            return(true);
        }
Beispiel #11
0
    private bool NetHandle_FlyToObject(eNetCmd cmd, UsCmd c)
    {
        int instID = c.ReadInt32();

        UsEditorNotifer.Instance.PostMessage_FlyToObject(instID);
        return(true);
    }
 private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c)
 {
     NetUtil.Log("eNetCmd.SV_HandshakeResponse received, connection validated.", (object[])Array.Empty <object>());
     SysPost.InvokeMulticast((object)this, (MulticastDelegate)this.LogicallyConnected);
     this._guardTimer.Deactivate();
     return(true);
 }
Beispiel #13
0
    private bool NetHandle_KeepAlive(string clientID, eNetCmd cmd, UsCmd c)
    {
        UsCmd reply = new UsCmd();

        reply.WriteNetCmd(eNetCmd.SV_KeepAliveResponse);
        SendCommand(clientID, reply);
        return(true);
    }
Beispiel #14
0
    private bool Handle_ExecCommandResponse(eNetCmd cmd, UsCmd c)
    {
        int code = c.ReadInt32();

        NetUtil.Log("command executing result: [b]{0}[/b]", code);

        return(true);
    }
    private bool NetHandle_KeepAlive(eNetCmd cmd, UsCmd c)
    {
        UsCmd reply = new UsCmd();

        reply.WriteNetCmd(eNetCmd.SV_KeepAliveResponse);
        UsNet.Instance.SendCommand(reply);
        return(true);
    }
Beispiel #16
0
    private bool NetHandle_KeepAlive(string clientID, eNetCmd cmd, UsCmd c)
    {
        UsCmd cmd1 = new UsCmd();

        cmd1.WriteNetCmd(eNetCmd.SV_KeepAliveResponse);
        this.SendCommand(clientID, cmd1);
        return(true);
    }
Beispiel #17
0
        private bool Handle_ExecCommandResponse(eNetCmd cmd, UsCmd c)
        {
            string ret = c.ReadString();

            UsLogging.Printf(string.Format("command executing result: [b]{0}[/b]", ret));

            return(true);
        }
Beispiel #18
0
    private bool NetHandle_Handshake(string clientID, eNetCmd cmd, UsCmd c)
    {
        this.NetLog("executing handshake.", (object[])Array.Empty <object>());
        UsCmd cmd1 = new UsCmd();

        cmd1.WriteNetCmd(eNetCmd.SV_HandshakeResponse);
        this.SendCommand(clientID, cmd1);
        return(true);
    }
Beispiel #19
0
        public void WriteNetCmd(eNetCmd cmd)
        {
            if (m_writeOffset != 0)
            {
                throw new System.Exception("net command should be written as the first 2 bytes.");
            }

            WriteInt16((short)cmd);
        }
Beispiel #20
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);
        }
Beispiel #21
0
    private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c)
    {
        NetUtil.Log("eNetCmd.SV_HandshakeResponse received, connection validated.");

        SysPost.InvokeMulticast(this, LogicallyConnected);

        _guardTimer.Deactivate();
        return(true);
    }
Beispiel #22
0
    private bool NetHandle_ExecCommand(eNetCmd cmd, UsCmd c)
    {
        string read  = c.ReadString();
        UsCmd  reply = new UsCmd();

        reply.WriteNetCmd(eNetCmd.SV_ExecCommandResponse);
        reply.WriteString(string.Format("str: {0}, len: {1}", read, read.Length));
        UsNet.Instance.SendCommand(reply);
        return(true);
    }
Beispiel #23
0
    private bool NetHandle_Handshake(string clientID, eNetCmd cmd, UsCmd c)
    {
        NetLog("executing handshake.");

        UsCmd reply = new UsCmd();

        reply.WriteNetCmd(eNetCmd.SV_HandshakeResponse);
        SendCommand(clientID, reply);
        return(true);
    }
Beispiel #24
0
 bool NetHandle_StartAnalysePixels(eNetCmd cmd, UsCmd c)
 {
     int count = c.ReadInt32();
     for (int i = 0; i < count; ++i )
     {
         string msg = c.ReadString();
         UsLogging.Printf(msg);
     }
     return true;
 }
Beispiel #25
0
    public bool NetHandle_SendLuaProfilerMsg(eNetCmd cmd, UsCmd c)
    {
        string data = c.ReadString();

        if (!string.IsNullOrEmpty(data))
        {
            sessionMsgList.Add(data);
        }
        return(true);
    }
    private bool NetHandle_ExecCommand(eNetCmd cmd, UsCmd c)
    {
        string fullcmd = c.ReadString();
        bool   flag    = UsvConsole.Instance.ExecuteCommand(fullcmd);
        UsCmd  cmd1    = new UsCmd();

        cmd1.WriteNetCmd(eNetCmd.SV_ExecCommandResponse);
        cmd1.WriteInt32(!flag ? 0 : 1);
        UsNet.Instance.SendCommand(cmd1);
        return(true);
    }
Beispiel #27
0
        bool NetHandle_StartAnalysePixels(eNetCmd cmd, UsCmd c)
        {
            int count = c.ReadInt32();

            for (int i = 0; i < count; ++i)
            {
                string msg = c.ReadString();
                UsLogging.Printf(msg);
            }
            return(true);
        }
    private bool NetHandle_ExecCommand(eNetCmd cmd, UsCmd c)
    {
        string read = c.ReadString();
        bool ret = UsvConsole.Instance.ExecuteCommand(read);

        UsCmd reply = new UsCmd();
        reply.WriteNetCmd(eNetCmd.SV_ExecCommandResponse);
        reply.WriteInt32 (ret ? 1 : 0);
        UsNet.Instance.SendCommand(reply);
        return true;
    }
    private bool NetHandle_ExecCommand(eNetCmd cmd, UsCmd c)
    {
        string read = c.ReadString();
        bool   ret  = UsvConsole.Instance.ExecuteCommand(read);

        UsCmd reply = new UsCmd();

        reply.WriteNetCmd(eNetCmd.SV_ExecCommandResponse);
        reply.WriteInt32(ret ? 1 : 0);
        UsNet.Instance.SendCommand(reply);
        return(true);
    }
    private bool NetHandle_Handshake(eNetCmd cmd, UsCmd c)
    {
        Debug.Log((object)"executing handshake.");
        if (!string.IsNullOrEmpty(LogService.LastLogFile))
        {
            Debug.Log((object)("Log Path: " + LogService.LastLogFile));
        }
        UsCmd cmd1 = new UsCmd();

        cmd1.WriteNetCmd(eNetCmd.SV_HandshakeResponse);
        UsNet.Instance.SendCommand(cmd1);
        return(true);
    }
Beispiel #31
0
    public bool Handle_VarTracerJsonParameter(eNetCmd cmd, UsCmd c)
    {
        var varTracerInfo = c.ReadString();

        if (string.IsNullOrEmpty(varTracerInfo))
        {
            return(false);
        }
        lock (_locker)
            VarTracerNet.Instance.VartracerJsonMsgList.Add(varTracerInfo);
        //NetUtil.Log("varTracer info{0}", varTracerInfo);
        return(true);
    }
Beispiel #32
0
        private bool Handle_QueryStacksResponse(eNetCmd cmd, UsCmd c)
        {
            var stackInfo = c.ReadString();

            if (string.IsNullOrEmpty(stackInfo))
            {
                return(false);
            }

            _stackInfoObj.writeStackInfo(stackInfo);
            NetUtil.Log("stack info{0}", stackInfo);
            return(true);
        }
        public bool Handle_VarTracerInfo(eNetCmd cmd, UsCmd c)
        {
            int groupCount = c.ReadInt32();

            //NetUtil.Log("read group count: {0}.", groupCount);

            for (int i = 0; i < groupCount; i++)
            {
                var groupName = c.ReadString();
                //NetUtil.Log("read group Name: {0}.", groupName);
                var variableCount = c.ReadInt32();
                //NetUtil.Log("read var count : {0}.", variableCount);
                for (int j = 0; j < variableCount; j++)
                {
                    var variableName = c.ReadString();
                    //NetUtil.Log("read variableName: {0}.", variableName);
                    var sessionCount = c.ReadInt32();
                    //NetUtil.Log("read sessionCount: {0}.", sessionCount);
                    for (int k = 0; k < sessionCount; k++)
                    {
                        long stamp = c.ReadLong();
                        if (VarTracerNet.Instance.StartTimeStamp == 0)
                        {
                            VarTracerNet.Instance.StartTimeStamp = VarTracerUtils.GetTimeStamp();
                            VarTracerNet.Instance.NetDeltaTime   = VarTracerNet.Instance.StartTimeStamp - stamp;
                        }
                        stamp += VarTracerNet.Instance.NetDeltaTime;

                        //NetUtil.Log("read stamp: {0}.", stamp);
                        float value = c.ReadFloat();
                        //NetUtil.Log("read value: {0}.", value);
                        VarTracerHandler.UpdateVariable(groupName, variableName, stamp, value);
                    }
                }

                var eventCount = c.ReadInt32();
                for (int j = 0; j < eventCount; j++)
                {
                    var eventName    = c.ReadString();
                    var sessionCount = c.ReadInt32();
                    for (int k = 0; k < sessionCount; k++)
                    {
                        long  stamp    = c.ReadLong();
                        float duration = c.ReadFloat();
                        VarTracerHandler.SendEvent(groupName, stamp, eventName, duration);
                    }
                }
            }

            return(true);
        }
Beispiel #34
0
        bool NetHandle_StressTestNames(eNetCmd cmd, UsCmd c)
        {
            var effects = new ObservableCollection<EffectObject>();
            int count = c.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var e = new EffectObject();
                e.Name = c.ReadString();
                effects.Add(e);
            }

            EffectGrid.Dispatcher.Invoke(new Action(() =>
            {
                EffectGrid.DataContext = effects;
            }));
            return true;
        }
Beispiel #35
0
        bool NetHandle_QuerySwitchesResponse(eNetCmd cmd, UsCmd c)
        {
            int count = c.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                string name = c.ReadString();
                string path = c.ReadString();
                short initVal = c.ReadInt16();

                _switchersPanel.Dispatcher.Invoke(new Action(() =>
                {
                    AddSwitcher(name, path, initVal != 0);
                }));
            }

            return true;
        }
Beispiel #36
0
        bool NetHandle_QuerySlidersResponse(eNetCmd cmd, UsCmd c)
        {
            int count = c.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                string name = c.ReadString();
                float minVal = c.ReadFloat();
                float maxVal = c.ReadFloat();
                float initVal = c.ReadFloat();

                _slidersPanel.Dispatcher.Invoke(new Action(() =>
                {
                    AddSlider(name, minVal, maxVal, initVal);
                }));
            }

            return true;
        }
Beispiel #37
0
        public bool NetHandle_FrameDataV2(eNetCmd cmd, UsCmd c)
        {
            int var = c.ReadInt32();
            float f1 = c.ReadFloat();
            f1 = c.ReadFloat();
            f1 = c.ReadFloat();
            var meshList = UsCmdUtil.ReadIntList(c);
            var materialList = UsCmdUtil.ReadIntList(c);
            var textureList = UsCmdUtil.ReadIntList(c);

            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                if (MeshGrid.DataContext == null)
                {
                    MeshGrid.DataContext = new ObservableCollection<MeshObject>();
                }
                else
                {
                    ((ObservableCollection<MeshObject>)(MeshGrid.DataContext)).Clear();
                }
            }));

            {
                UsCmd req = new UsCmd();
                req.WriteNetCmd(eNetCmd.CL_FrameV2_RequestMeshes);
                UsCmdUtil.WriteIntList(req, meshList);
                NetManager.Instance.Send(req);
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2 [b]({0} meshes expected)[/b].", meshList.Count);
            }

            {
                UsCmd req = new UsCmd();
                req.WriteNetCmd(eNetCmd.CL_FrameV2_RequestNames);
                UsCmdUtil.WriteIntList(req, meshList);
                NetManager.Instance.Send(req);
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2 [b]({0} names expected)[/b].", meshList.Count);
            }

            return true;
        }
 private bool NetHandle_KeepAlive(eNetCmd cmd, UsCmd c)
 {
     UsCmd reply = new UsCmd();
     reply.WriteNetCmd(eNetCmd.SV_KeepAliveResponse);
     UsNet.Instance.SendCommand(reply);
     return true;
 }
Beispiel #39
0
 public void RegisterCmdHandler(eNetCmd cmd, UsCmdHandler handler)
 {
     _cmdParser.RegisterHandler(cmd, handler);
 }
    private bool NetHandle_QuerySwitches(eNetCmd cmd, UsCmd c)
    {
        UsCmd pkt = new UsCmd();
        pkt.WriteNetCmd(eNetCmd.SV_QuerySwitchesResponse);

        pkt.WriteInt32(GameInterface.ObjectNames.Count);
        foreach (var name in GameInterface.ObjectNames)
        {
            //Log.Info("{0} {1} switch added.", name.Key, name.Value);
            pkt.WriteString(name.Key);
            pkt.WriteString(name.Value);
            pkt.WriteInt16(1);
        }
        UsNet.Instance.SendCommand(pkt);

        return true;
    }
 private bool NetHandle_FlyToObject(eNetCmd cmd, UsCmd c)
 {
     int instID = c.ReadInt32 ();
     UsEditorNotifer.Instance.PostMessage_FlyToObject (instID);
     return true;
 }
    private bool NetHandle_FrameV2_RequestNames(eNetCmd cmd, UsCmd c)
    {
        if (DataCollector.Instance != null) {
            List<int> instIDs = UsCmdUtil.ReadIntList(c);
            foreach (var slice in UsGeneric.Slice(instIDs, SLICE_COUNT)) {
                UsCmd fragment = new UsCmd();
                fragment.WriteNetCmd(eNetCmd.SV_FrameDataV2_Names);
                fragment.WriteInt32 (slice.Count);
                foreach (int instID in slice) {
                    DataCollector.Instance.WriteName(instID, fragment);
                }
                UsNet.Instance.SendCommand (fragment);
            }
        }

        return true;
    }
    private bool NetHandle_FrameV2_RequestMeshes(eNetCmd cmd, UsCmd c)
    {
        if (DataCollector.Instance != null) {
            List<int> meshIDs = UsCmdUtil.ReadIntList(c);
            //Debug.Log(string.Format("requesting meshes - count ({0})", meshIDs.Count));
            foreach (var slice in UsGeneric.Slice(meshIDs, SLICE_COUNT)) {
                UsCmd fragment = new UsCmd();
                fragment.WriteNetCmd(eNetCmd.SV_FrameDataV2_Meshes);
                fragment.WriteInt32 (slice.Count);
                foreach (int meshID in slice) {
                    DataCollector.Instance.MeshTable.WriteMesh(meshID, fragment);
                }
                UsNet.Instance.SendCommand (fragment);
            }
        }

        return true;
    }
Beispiel #44
0
        public bool NetHandle_FrameData_Texture(eNetCmd cmd, UsCmd c)
        {
            UsLogging.Printf("eNetCmd.Handle_FrameData_Texture received ({0}).", c.Buffer.Length);

            var textures = new ObservableCollection<TextureObject>();
            int count = c.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var m = new TextureObject();
                m.InstID = c.ReadInt32();
                m.Name = c.ReadString();
                m.PixelSize = c.ReadString();
                m.MemSize = c.ReadString();
                m.RefCnt = c.ReadInt32();
                m.RefList = new List<int>();
                for (int k = 0; k < m.RefCnt; k++)
                {
                    int owner = c.ReadInt32();
                    m.RefList.Add(owner);
                }

                textures.Add(m);
            }

            TextureGrid.Dispatcher.Invoke(new Action(() =>
            {
                title_texture.Text = string.Format("Textures ({0})", textures.Count);
                TextureGrid.DataContext = textures;
            }));
            return true;
        }
Beispiel #45
0
 public void RegisterHandler(eNetCmd cmd, UsCmdHandler handler)
 {
     m_handlers[cmd] = handler;
 }
Beispiel #46
0
        public bool NetHandle_FrameData_Material(eNetCmd cmd, UsCmd c)
        {
            UsLogging.Printf("eNetCmd.Handle_FrameData_Material received ({0}).", c.Buffer.Length);

            var materials = new ObservableCollection<MaterialObject>();
            int count = c.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                var m = new MaterialObject();
                m.InstID = c.ReadInt32();
                m.Name = c.ReadString();
                m.ShaderName = c.ReadString();
                m.RefCnt = c.ReadInt32();

                m.RefList = new List<int>();
                for (int k = 0; k < m.RefCnt; k++)
                {
                    int owner = c.ReadInt32();
                    m.RefList.Add(owner);
                }

                materials.Add(m);
            }

            MaterialGrid.Dispatcher.Invoke(new Action(() =>
            {
                title_material.Text = string.Format("Materials ({0})", materials.Count);
                MaterialGrid.DataContext = materials;
            }));
            return true;
        }
    private bool NetHandle_RequestFrameData(eNetCmd cmd, UsCmd c)
    {
        if (DataCollector.Instance == null)
            return true;

        FrameData data = DataCollector.Instance.CollectFrameData();

        UsNet.Instance.SendCommand(data.CreatePacket());
        UsNet.Instance.SendCommand(DataCollector.Instance.CreateMaterialCmd());
        UsNet.Instance.SendCommand(DataCollector.Instance.CreateTextureCmd());

        UsCmd end = new UsCmd();
        end.WriteNetCmd(eNetCmd.SV_FrameDataEnd);
        UsNet.Instance.SendCommand (end);

        //Debug.Log(string.Format("creating frame packet: id {0} mesh count {1}", eNetCmd.SV_FrameDataV2, data._frameMeshes.Count));

        return true;
    }
Beispiel #48
0
 public void RegisterCmdHandler(eNetCmd cmd, UsCmdHandler handler)
 {
     _client.RegisterCmdHandler(cmd, handler);
 }
    private bool NetHandle_QuerySliders(eNetCmd cmd, UsCmd c)
    {
        UsCmd pkt = new UsCmd();
        pkt.WriteNetCmd(eNetCmd.SV_QuerySlidersResponse);

        pkt.WriteInt32(GameInterface.VisiblePercentages.Count);
        foreach (var p in GameInterface.VisiblePercentages)
        {
            //Log.Info("{0} slider added.", p.Key);
            pkt.WriteString(p.Key);
            pkt.WriteFloat(0.0f);
            pkt.WriteFloat(100.0f);
            pkt.WriteFloat((float)p.Value);
        }
        UsNet.Instance.SendCommand(pkt);

        return true;
    }
Beispiel #50
0
        public bool NetHandle_FrameDataV2_Meshes(eNetCmd cmd, UsCmd c)
        {
            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                int count = c.ReadInt32();
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2_Meshes [b]({0} got)[/b].", count);
                for (int i = 0; i < count; i++)
                {
                    var m = new MeshObject();
                    m.Visible = true;
                    m.InstID = c.ReadInt32();
                    m.VertCnt = c.ReadInt32();
                    m.TriCnt = c.ReadInt32();
                    m.MatCnt = c.ReadInt32();
                    m.Size = c.ReadFloat();
                    ((ObservableCollection<MeshObject>)(MeshGrid.DataContext)).Add(m);
                }
            }));

            return true;
        }
Beispiel #51
0
        public bool NetHandle_FrameDataV2_Names(eNetCmd cmd, UsCmd c)
        {
            MeshGrid.Dispatcher.Invoke(new Action(() =>
            {
                int count = c.ReadInt32();
                UsLogging.Printf("eNetCmd.NetHandle_FrameDataV2_Names [b]({0} got)[/b].", count);
                for (int i = 0; i < count; i++)
                {
                    int instID = c.ReadInt32();
                    string instName = c.ReadString();
                    foreach (var item in MeshGrid.Items)
                    {
                        MeshObject mo = item as MeshObject;
                        if (mo != null && mo.InstID == instID)
                        {
                            mo.Name = instName;
                        }
                    }
                }

                MeshGrid.Items.Refresh();
            }));

            return true;
        }
Beispiel #52
0
        private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c)
        {
            UsLogging.Printf("eNetCmd.SV_HandshakeResponse received, connection validated.");

            SysPost.InvokeMulticast(this, LogicallyConnected);

            _guardTimer.Deactivate();
            return true;
        }
    private bool NetHandle_Handshake(eNetCmd cmd, UsCmd c)
    {
        Debug.Log("executing handshake.");
        if (!string.IsNullOrEmpty(LogService.LastLogFile))
        {
            Debug.Log("Log Path: " + LogService.LastLogFile);
        }

        UsCmd reply = new UsCmd();
        reply.WriteNetCmd(eNetCmd.SV_HandshakeResponse);
        UsNet.Instance.SendCommand(reply);
        return true;
    }
Beispiel #54
0
 private bool Handle_KeepAliveResponse(eNetCmd cmd, UsCmd c)
 {
     //UsLogging.Printf("'KeepAlive' received.");
     return true;
 }
Beispiel #55
0
        bool NetHandle_StressTestResult(eNetCmd cmd, UsCmd c)
        {
            string name = c.ReadString();
            int avgMS = c.ReadInt32();
            int maxMS = c.ReadInt32();
            int drawcall = c.ReadInt32();
            int parCount = c.ReadInt32();

            EffectGrid.Dispatcher.Invoke(new Action(() =>
            {
                foreach (var item in EffectGrid.Items)
                {
                    EffectObject mo = item as EffectObject;
                    if (mo != null && mo.Name == name)
                    {
                        if (_highlighted != null)
                        {
                            DataGridUtil.ClearHighlighted(EffectGrid, _highlighted);
                        }

                        mo.MSAvg = avgMS;
                        mo.MSMax = maxMS;
                        mo.DrawCallCount = drawcall;
                        mo.TotalParticles = parCount;

                        DataGridUtil.MarkAsHighlighted(EffectGrid, item, Colors.Chartreuse);
                        _highlighted = mo;

                        break;
                    }
                }
            }));

            RunNextEffectStressTest();

            return true;
        }
Beispiel #56
0
 private bool Handle_ServerLogging(eNetCmd cmd, UsCmd c)
 {
     UsLogPacket pkt = new UsLogPacket(c);
     UsNetLogging.Print(pkt);
     return true;
 }
Beispiel #57
0
        private bool Handle_ExecCommandResponse(eNetCmd cmd, UsCmd c)
        {
            int code = c.ReadInt32();
            UsLogging.Printf(string.Format("command executing result: [b]{0}[/b]", code));

            return true;
        }
Beispiel #58
0
 public bool NetHandle_FrameDataEnd(eNetCmd cmd, UsCmd c)
 {
     return true;
 }