forked from powerfun/udpservice
虚拟人物
This commit is contained in:
1 parent
12d1a01543
commit
81409dca9e
6 files changed
+163
-39
No files matched your search
@@ -18,6 +18,7 @@ using Newtonsoft.Json;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO.Compression;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
namespace OnlineUserPool.ViewModels
|
||||
{
|
||||
@@ -52,8 +53,28 @@ namespace OnlineUserPool.ViewModels
|
||||
SetProperty(ref _SendDataSize, value);
|
||||
}
|
||||
}
|
||||
private string _VirtualData = "";
|
||||
public string VirtualData
|
||||
{
|
||||
get { return _VirtualData; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref _VirtualData, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _closeVirtualUser = false;
|
||||
public bool CloseVirtualUser
|
||||
{
|
||||
get { return _closeVirtualUser; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref _closeVirtualUser, value);
|
||||
}
|
||||
}
|
||||
|
||||
//private IService _udpService;
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
Title = $"{ IPAddress.Any }:{ ConfigHelp.UdpPort }";
|
||||
@@ -63,7 +84,7 @@ namespace OnlineUserPool.ViewModels
|
||||
//Customers.Add("suntao");
|
||||
WriteLine(DateTime.Now.ToShortDateString());
|
||||
LogHelper.Init();
|
||||
mapRecordRankingHander = new MapRecordRankingHander();//new MultiUserHandle();//
|
||||
mapRecordRankingHander = new MapRecordRankingHander();//
|
||||
//mapRecordRankingHander = new MultiUserHandle();
|
||||
Log.Information($"初始化连接,当前地址:{ IPAddress.Any }:{ConfigHelp.UdpPort}");
|
||||
|
||||
@@ -199,15 +220,19 @@ namespace OnlineUserPool.ViewModels
|
||||
var msgs = CloneJson(receiveMes).ToList();
|
||||
receiveMes.Clear();
|
||||
|
||||
//加入虚拟人物消息
|
||||
var virtualData = mapRecordRankingHander.GetVirtualUserData();
|
||||
WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-当前在线人数:" + Clients.Count + "-当前虚拟人数:" + virtualData.Count);
|
||||
if (!CloseVirtualUser)
|
||||
{
|
||||
//加入虚拟人物消息
|
||||
var virtualData = mapRecordRankingHander.GetVirtualUserData();
|
||||
VirtualData = $"{virtualData.Count}";
|
||||
WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-当前在线人数:" + Clients.Count + "-当前虚拟人数:" + virtualData.Count);
|
||||
|
||||
#if DEBUG
|
||||
WriteLine($"在线人:{Newtonsoft.Json.JsonConvert.SerializeObject(msgs)}");
|
||||
//\r\n虚拟人:{Newtonsoft.Json.JsonConvert.SerializeObject(virtualData)}
|
||||
#endif
|
||||
msgs.AddRange(virtualData);
|
||||
WriteLine($"在线人:{Newtonsoft.Json.JsonConvert.SerializeObject(msgs)}");
|
||||
//\r\n虚拟人:{Newtonsoft.Json.JsonConvert.SerializeObject(virtualData)}
|
||||
#endif
|
||||
msgs.AddRange(virtualData);
|
||||
}
|
||||
|
||||
SendMessage(Clients, msgs);
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30320.27
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OnlineUserPool", "OnlineUserPool.csproj", "{5E6C3E3A-13CE-4DBE-8352-E45D01E9F743}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5E6C3E3A-13CE-4DBE-8352-E45D01E9F743}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5E6C3E3A-13CE-4DBE-8352-E45D01E9F743}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5E6C3E3A-13CE-4DBE-8352-E45D01E9F743}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5E6C3E3A-13CE-4DBE-8352-E45D01E9F743}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {21B354CA-A2B2-4F3E-B971-C742C9BEAA53}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in new issue
Block a user