上传c#战斗服务

This commit is contained in:
liwei1dao 2022-12-12 16:04:28 +08:00
parent bf6293aebb
commit 0648f41645
14 changed files with 20 additions and 11 deletions

View File

@ -34,16 +34,24 @@ namespace BattleServer
/// <param name="msg"></param>
private void handle(BattleRpcMessage msg)
{
Console.WriteLine("收到战斗消息:{0}", msg.ToString());
int end = battle.Manager.CheckBattle((int)msg.rid);
Console.WriteLine("CheckBattle:{0}", end);
try{
Console.WriteLine("收到战斗消息:{0}", msg.method);
switch(msg.method){
case "Check":
BattleReport report = ProtoDeSerialize<BattleReport>(msg.Data.value);
HotUpdateScripts.FightRunnerMgr.Instance.StartOnceFight(report);
BattleReport report = ProtoDeSerialize<BattleReport>(msg.data.value);
bool ischeck = HotUpdateScripts.FightRunnerMgr.Instance.VerifyOnceFight(report);
Console.WriteLine("战斗校验结果:{0}", ischeck);
msg.data = new Google.Protobuf.WellKnownTypes.Any {
type_url = "type.googleapis.com/BattleCheckResults",
value = ProtoSerialize(new BattleCheckResults{ischeck=ischeck}),
};
socket.Send(ProtoSerialize(msg));
break;
}
} catch (IOException ex){
Console.WriteLine("战斗异常 {0}",ex.Message);
socket.Close();
}
}
/// <summary>
@ -70,6 +78,7 @@ namespace BattleServer
/// <returns></returns>
public static T ProtoDeSerialize<T>(byte[] msg) where T : class
{
msg = msg == null ? new byte[]{} : msg;
using (var ms = new MemoryStream(msg))
{
var data = ProtoBuf.Serializer.Deserialize<T>(ms);

View File

@ -10,7 +10,7 @@ namespace BattleServer
{
HotUpdateScripts.FightRunnerMgr.Instance.Init("./GameConfig/");
cfg.Game.HeroData data = HotUpdateScripts.FightBase.GC.Hero.Get("25001");
HotUpdateScripts.FightDebug.Log("name:"+data.Name);
HotUpdateScripts.FightDebug.Log("测试读取配置 name:"+data.Name);
Console.WriteLine("BattleServer Start!");
Service service = new Service();
Console.ReadKey();

View File

@ -15,7 +15,7 @@ namespace BattleServer
public Service()
{
var server = new WebSocketServer("ws://127.0.0.1:9898"); //创建webscoket服务端实例
var server = new WebSocketServer("ws://127.0.0.1:9897"); //创建webscoket服务端实例
server.Start(onAccept);
clients = new List<Client>();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.