public UsLogPacket(UsCmd c) { SeqID = (ushort)c.ReadInt16(); LogType = (UsLogType)c.ReadInt32(); Content = c.ReadString(); RealtimeSinceStartup = c.ReadFloat(); }
public void WriteMesh(int instID, UsCmd cmd) { MeshData data; if (_lut.TryGetValue(instID, out data)) { data.Write(cmd); } }
public static void WriteIntList(UsCmd c, List<int> l) { c.WriteInt32 (l.Count); foreach (var item in l) { c.WriteInt32 (item); } }
private void OnLogicallyConnected(object sender, EventArgs e) { this.Dispatcher.Invoke(new Action(() => { cb_targetIP.IsEnabled = false; bt_connect.IsEnabled = false; bt_disconnect.IsEnabled = true; string remoteAddr = cb_targetIP.Text; UsLogging.Printf(LogWndOpt.Bold, "connected to [u]{0}[/u].", remoteAddr); if (AppSettingsUtil.AppendAsRecentlyConnected(remoteAddr)) { cb_targetIP.Items.Add(remoteAddr); UsLogging.Printf("{0} is appended into the recent connection list.", remoteAddr); } // query switches and sliders { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.CL_QuerySwitches); NetManager.Instance.Send(cmd); } { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.CL_QuerySliders); NetManager.Instance.Send(cmd); } })); }
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; }
public UsCmdExecResult Execute(UsCmd c) { try { eNetCmd cmd = c.ReadNetCmd(); UsCmdHandler handler; if (!m_handlers.TryGetValue(cmd, out handler)) { return UsCmdExecResult.HandlerNotFound; } if (handler(cmd, c)) { return UsCmdExecResult.Succ; } else { return UsCmdExecResult.Failed; } } catch (Exception ex) { Console.WriteLine("[cmd] Execution failed. ({0})", ex.Message); return UsCmdExecResult.Failed; } }
public static List<int> ReadIntList(UsCmd c) { List<int> ret = new List<int>(); int count = c.ReadInt32 (); for (int i = 0; i < count; i++) { ret.Add(c.ReadInt32()); } return ret; }
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; }
public UsCmd CreatePacket() { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.SV_FrameDataV2); cmd.WriteInt32(_frameCount); cmd.WriteFloat(_frameDeltaTime); cmd.WriteFloat(_frameRealTime); cmd.WriteFloat(_frameStartTime); UsCmdUtil.WriteIntList(cmd, _frameMeshes); UsCmdUtil.WriteIntList(cmd, _frameMaterials); UsCmdUtil.WriteIntList(cmd, _frameTextures); return cmd; }
private void requestStackDataInfo() { var selectNat = _selectedThing as NativeUnityEngineObject; if (selectNat == null) { return; } UsCmd cmd = new UsCmd(); cmd.WriteInt16((short)eNetCmd.CL_RequestStackData); cmd.WriteInt32(selectNat.instanceID); cmd.WriteString(getRemoveDiffTypeStr(selectNat)); NetManager.Instance.Send(cmd); }
private bool NetHandle_QuerySwitches(eNetCmd cmd, UsCmd c) { UsCmd cmd1 = new UsCmd(); cmd1.WriteNetCmd(eNetCmd.SV_QuerySwitchesResponse); cmd1.WriteInt32(GameInterface.ObjectNames.Count); foreach (KeyValuePair <string, string> objectName in GameInterface.ObjectNames) { cmd1.WriteString(objectName.Key); cmd1.WriteString(objectName.Value); cmd1.WriteInt16((short)1); } UsNet.Instance.SendCommand(cmd1); return(true); }
private bool NetHandle_QuerySliders(eNetCmd cmd, UsCmd c) { UsCmd cmd1 = new UsCmd(); cmd1.WriteNetCmd(eNetCmd.SV_QuerySlidersResponse); cmd1.WriteInt32(GameInterface.VisiblePercentages.Count); foreach (KeyValuePair <string, double> visiblePercentage in GameInterface.VisiblePercentages) { cmd1.WriteString(visiblePercentage.Key); cmd1.WriteFloat(0.0f); cmd1.WriteFloat(100f); cmd1.WriteFloat((float)visiblePercentage.Value); } UsNet.Instance.SendCommand(cmd1); return(true); }
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; }
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; }
private bool NetHandle_RequestFrameData(eNetCmd cmd, UsCmd c) { if (DataCollector.Instance == null) { return(true); } FrameData frameData = DataCollector.Instance.CollectFrameData(); UsNet.Instance.SendCommand(frameData.CreatePacket()); UsNet.Instance.SendCommand(DataCollector.Instance.CreateMaterialCmd()); UsNet.Instance.SendCommand(DataCollector.Instance.CreateTextureCmd()); UsCmd cmd1 = new UsCmd(); cmd1.WriteNetCmd(eNetCmd.SV_FrameDataEnd); UsNet.Instance.SendCommand(cmd1); 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()); //Debug.Log(string.Format("creating frame packet: id {0} mesh count {1}", eNetCmd.SV_FrameDataV2, data._frameMeshes.Count)); return(true); }
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; }
private bool NetHandle_FrameV2_RequestNames(eNetCmd cmd, UsCmd c) { if (DataCollector.Instance != null) { foreach (List <int> intList in UsGeneric.Slice <int>(UsCmdUtil.ReadIntList(c), this.SLICE_COUNT)) { UsCmd cmd1 = new UsCmd(); cmd1.WriteNetCmd(eNetCmd.SV_FrameDataV2_Names); cmd1.WriteInt32(intList.Count); foreach (int instID in intList) { DataCollector.Instance.WriteName(instID, cmd1); } UsNet.Instance.SendCommand(cmd1); } } return(true); }
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); }
public UsCmdExecResult ExecuteClient(string clientID, UsCmd c) { try { eNetCmd eNetCmd = c.ReadNetCmd(); UsClientCmdHandler clientCmdHandler; if (!this.m_clientHandlers.TryGetValue(eNetCmd, out clientCmdHandler)) { return(UsCmdExecResult.HandlerNotFound); } return(clientCmdHandler(clientID, eNetCmd, c) ? UsCmdExecResult.Succ : UsCmdExecResult.Failed); } catch (Exception ex) { Console.WriteLine("[cmd] Execution failed. ({0})", (object)ex.Message); return(UsCmdExecResult.Failed); } }
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); }
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); }
public void ExecuteCmd(string cmdText) { if (!this.IsConnected) { NetUtil.Log("not connected to server, command ignored.", (object[])Array.Empty <object>()); } else if (cmdText.Length == 0) { NetUtil.Log("the command bar is empty, try 'help' to list all supported commands.", (object[])Array.Empty <object>()); } else { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.CL_ExecCommand); cmd.WriteString(cmdText); this.Send(cmd); NetUtil.Log("command executed: [b]{0}[/b]", (object)cmdText); } }
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); }
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); }
public void OnSelectionChange() { _selectedIDs = Selection.instanceIDs; if (UsNet.Instance != null) { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.SV_Editor_SelectionChanged); cmd.WriteInt32(_selectedIDs.Length); //Debug.Log(string.Format("selection count: {0}", _selectedIDs.Length)); foreach (int item in _selectedIDs) { cmd.WriteInt32(item); } UsNet.Instance.SendCommand(cmd); } Repaint(); }
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(); } title_mesh.Text = string.Format("Meshes ({0})", meshList.Count); })); { 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_FrameV2_RequestNames(eNetCmd cmd, UsCmd c) { if (usmooth.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) { usmooth.DataCollector.Instance.WriteName(instID, fragment); } UsNet.Instance.SendCommand(fragment); } } return(true); }
private 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.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); }
private bool NetHandle_FrameV2_RequestMeshes(eNetCmd cmd, UsCmd c) { if (usmooth.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) { usmooth.DataCollector.Instance.MeshTable.WriteMesh(meshID, fragment); } UsNet.Instance.SendCommand(fragment); } } return(true); }
public bool NetHandle_RequestStackData(eNetCmd cmd, UsCmd c) { int instID = c.ReadInt32(); string str = c.ReadString(); Debug.Log((object)string.Format("NetHandle_RequestStackData instanceID={0} className={1}", (object)instID, (object)str)); ResourceRequestInfo allocInfo = ResourceTracker.Instance.GetAllocInfo(instID); UsCmd cmd1 = new UsCmd(); cmd1.WriteNetCmd(eNetCmd.SV_QueryStacksResponse); if (allocInfo == null) { cmd1.WriteString("<no_callstack_available>"); } else { cmd1.WriteString(ResourceTracker.Instance.GetStackTrace(allocInfo)); } UsNet.Instance.SendCommand(cmd1); return(true); }
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; }
public void Tick_ReceivingData() { try { while (_tcpClient.Available > 0) { byte[] cmdLenBuf = new byte[2]; int cmdLenRead = _tcpClient.GetStream().Read(cmdLenBuf, 0, cmdLenBuf.Length); ushort cmdLen = BitConverter.ToUInt16(cmdLenBuf, 0); if (cmdLenRead > 0 && cmdLen > 0) { byte[] buffer = new byte[cmdLen]; int len = _tcpClient.GetStream().Read(buffer, 0, buffer.Length); UsCmd cmd = new UsCmd(buffer); UsCmdExecResult result = _cmdParser.Execute(cmd); switch (result) { case UsCmdExecResult.Succ: break; case UsCmdExecResult.Failed: NetUtil.Log("net cmd execution failed: {0}.", new UsCmd(buffer).ReadNetCmd()); break; case UsCmdExecResult.HandlerNotFound: NetUtil.Log("net unknown cmd: {0}.", new UsCmd(buffer).ReadNetCmd()); break; } len++; // warning CS0219: The variable `len' is assigned but its value is never used } } } catch (Exception ex) { DisconnectOnError("error detected while receiving data.", ex); } }
public static void OnMessage(string data) { Debug.Assert(Instance != null); if (Instance == null) { return; } Debug.Assert(!string.IsNullOrEmpty(data)); if (string.IsNullOrEmpty(data)) { return; } if (Instance._networkAvailable) { UsCmd cmd = new UsCmd(); cmd.WriteInt16((short)eNetCmd.SV_SendLuaProfilerMsg); cmd.WriteString(data); UsNet.Instance.SendCommand(cmd); } }
public void ExecuteCmd(string cmdText) { if (!IsConnected) { UsLogging.Printf(LogWndOpt.Bold, "not connected to server, command ignored."); return; } if (cmdText.Length == 0) { UsLogging.Printf(LogWndOpt.Bold, "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); UsLogging.Printf(string.Format("command executed: [b]{0}[/b]", cmdText)); }
public UsCmd CreateMaterialCmd() { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.SV_FrameData_Material); cmd.WriteInt32(VisibleMaterials.Count); foreach (KeyValuePair <Material, HashSet <GameObject> > kv in VisibleMaterials) { //Debug.Log (string.Format("current_material: {0} - {1} - {2}", kv.Key.GetInstanceID(), kv.Key.name.Length, kv.Key.name)); cmd.WriteInt32(kv.Key.GetInstanceID()); cmd.WriteStringStripped(kv.Key.name); cmd.WriteStringStripped(kv.Key.shader.name); cmd.WriteInt32(kv.Value.Count); foreach (var item in kv.Value) { cmd.WriteInt32(item.GetInstanceID()); } } return(cmd); }
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); }
private void ExecInputCmd() { if (!AppNetManager.Instance.IsConnected) { UsLogging.Printf(LogWndOpt.Bold, "not connected to server, command ignored."); return; } if (tb_cmdbox.Text.Length == 0) { UsLogging.Printf(LogWndOpt.Bold, "the command bar is empty, try 'help' to list all supported commands."); return; } UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.CL_ExecCommand); cmd.WriteString(tb_cmdbox.Text); AppNetManager.Instance.Send(cmd); UsLogging.Printf(string.Format("command executed: [b]{0}[/b]", tb_cmdbox.Text)); tb_cmdbox.Clear(); }
public bool NetHandle_RequestStackData(eNetCmd cmd, UsCmd c) { int instanceID = c.ReadInt32(); string className = c.ReadString(); UnityEngine.Debug.Log(string.Format("NetHandle_RequestStackData instanceID={0} className={1}", instanceID, className)); ResourceRequestInfo requestInfo = ResourceTracker.Instance.GetAllocInfo(instanceID); UsCmd pkt = new UsCmd(); pkt.WriteNetCmd(eNetCmd.SV_QueryStacksResponse); if (requestInfo == null) { pkt.WriteString("<no_callstack_available>"); } else { pkt.WriteString(ResourceTracker.Instance.GetStackTrace(requestInfo)); } UsNet.Instance.SendCommand(pkt); return(true); }
public UsCmd CreateTextureCmd() { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.SV_FrameData_Texture); cmd.WriteInt32(VisibleTextures.Count); foreach (KeyValuePair <Texture, HashSet <Material> > kv in VisibleTextures) { cmd.WriteInt32(kv.Key.GetInstanceID()); cmd.WriteStringStripped(kv.Key.name); cmd.WriteString(string.Format("{0}x{1}", kv.Key.width, kv.Key.height)); cmd.WriteString(UsTextureUtil.FormatSizeString(_textureSizeLut[kv.Key] / 1024)); cmd.WriteInt32(kv.Value.Count); foreach (var item in kv.Value) { cmd.WriteInt32(item.GetInstanceID()); } } return(cmd); }
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); }
private void Tick() { _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; } }
public void Send(UsCmd cmd) { this._client.SendPacket(cmd); }
public UsCmd CreateMaterialCmd() { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.SV_FrameData_Material); cmd.WriteInt32 (VisibleMaterials.Count); foreach (KeyValuePair<Material, HashSet<GameObject>> kv in VisibleMaterials) { //Debug.Log (string.Format("current_material: {0} - {1} - {2}", kv.Key.GetInstanceID(), kv.Key.name.Length, kv.Key.name)); cmd.WriteInt32 (kv.Key.GetInstanceID()); cmd.WriteStringStripped (kv.Key.name); cmd.WriteStringStripped (kv.Key.shader.name); cmd.WriteInt32 (kv.Value.Count); foreach (var item in kv.Value) { cmd.WriteInt32 (item.GetInstanceID()); } } return cmd; }
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; }
public UsCmd CreateTextureCmd() { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.SV_FrameData_Texture); cmd.WriteInt32 (VisibleTextures.Count); foreach (KeyValuePair<Texture, HashSet<Material>> kv in VisibleTextures) { cmd.WriteInt32 (kv.Key.GetInstanceID()); cmd.WriteStringStripped (kv.Key.name); cmd.WriteString (string.Format("{0}x{1}", kv.Key.width, kv.Key.height)); cmd.WriteString (UsTextureUtil.FormatSizeString(_textureSizeLut[kv.Key] / 1024)); cmd.WriteInt32 (kv.Value.Count); foreach (var item in kv.Value) { cmd.WriteInt32 (item.GetInstanceID()); } } return cmd; }
public void OnSelectionChange() { _selectedIDs = Selection.instanceIDs; if (UsNet.Instance != null) { UsCmd cmd = new UsCmd(); cmd.WriteNetCmd(eNetCmd.SV_Editor_SelectionChanged); cmd.WriteInt32 (_selectedIDs.Length); //Debug.Log(string.Format("selection count: {0}", _selectedIDs.Length)); foreach (int item in _selectedIDs) { cmd.WriteInt32 (item); } UsNet.Instance.SendCommand(cmd); } Repaint (); }
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; }
private bool Handle_ServerLogging(eNetCmd cmd, UsCmd c) { UsLogPacket pkt = new UsLogPacket(c); UsNetLogging.Print(pkt); return true; }
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; } }
private bool Handle_KeepAliveResponse(eNetCmd cmd, UsCmd c) { //UsLogging.Printf("'KeepAlive' received."); return true; }
public void WriteName(int instID, UsCmd cmd) { string data; if (_nameLut.TryGetValue(instID, out data)) { cmd.WriteInt32 (instID); cmd.WriteStringStripped (data); } }
public void SendPacket(UsCmd cmd) { try { byte[] cmdLenBytes = BitConverter.GetBytes((ushort)cmd.WrittenLen); _tcpClient.GetStream().Write(cmdLenBytes, 0, cmdLenBytes.Length); _tcpClient.GetStream().Write(cmd.Buffer, 0, cmd.WrittenLen); } catch (Exception ex) { DisconnectOnError("error detected while sending data.", ex); } }
public void Write(UsCmd cmd) { cmd.WriteInt32(_instID); cmd.WriteInt32(_vertCount); cmd.WriteInt32(_triCount); cmd.WriteInt32(_materialCount); cmd.WriteFloat(_boundSize); }
private void OnConnected(object sender, EventArgs e) { UsCmd cmd = new UsCmd(); cmd.WriteInt16((short)eNetCmd.CL_Handshake); cmd.WriteInt16(Properties.Settings.Default.VersionMajor); cmd.WriteInt16(Properties.Settings.Default.VersionMinor); cmd.WriteInt16(Properties.Settings.Default.VersionPatch); _client.SendPacket(cmd); _tickTimer.Start(); _guardTimer.Activate(); }
public void Send(UsCmd cmd) { _client.SendPacket(cmd); }
private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c) { UsLogging.Printf("eNetCmd.SV_HandshakeResponse received, connection validated."); SysPost.InvokeMulticast(this, LogicallyConnected); _guardTimer.Deactivate(); return true; }
public void Tick_ReceivingData() { try { while (_tcpClient.Available > 0) { byte[] cmdLenBuf = new byte[2]; int cmdLenRead = _tcpClient.GetStream().Read(cmdLenBuf, 0, cmdLenBuf.Length); ushort cmdLen = BitConverter.ToUInt16(cmdLenBuf, 0); if (cmdLenRead > 0 && cmdLen > 0) { byte[] buffer = new byte[cmdLen]; int len = _tcpClient.GetStream().Read(buffer, 0, buffer.Length); UsCmd cmd = new UsCmd(buffer); UsCmdExecResult result = _cmdParser.Execute(cmd); switch (result) { case UsCmdExecResult.Succ: break; case UsCmdExecResult.Failed: UsLogging.Printf("net cmd execution failed: {0}.", new UsCmd(buffer).ReadNetCmd()); break; case UsCmdExecResult.HandlerNotFound: UsLogging.Printf("net unknown cmd: {0}.", new UsCmd(buffer).ReadNetCmd()); break; } } } } catch (Exception ex) { DisconnectOnError("error detected while receiving data.", ex); } }