Browse Source

Merge pull request #179 from gsy1519/dev

fix: fix some bugs
tags/0.1.0
TCL GitHub 2 years ago
parent
commit
a1ed1b8458
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions
  1. +4
    -1
      logic/Server/ArgumentOption.cs
  2. +4
    -2
      logic/Server/GameServer.cs
  3. +3
    -3
      logic/Server/Program.cs
  4. +1
    -1
      logic/Server/Properties/launchSettings.json

+ 4
- 1
logic/Server/ArgumentOption.cs View File

@@ -12,8 +12,11 @@ namespace Server

public class ArgumentOptions
{
[Option("ip", Required = true, HelpText = "Server listening port")]
public string ServerIP { get; set; } = "0.0.0.0";

[Option('p', "port", Required = true, HelpText = "Server listening port")]
public ushort ServerPort { get; set; } = 10086;
public ushort ServerPort { get; set; } = 8888;

[Option('n', "playerNum", Required = false, HelpText = "The number of teams, 1 by defualt")]
public ushort playerNum { get; set; } = 1;


+ 4
- 2
logic/Server/GameServer.cs View File

@@ -468,7 +468,8 @@ namespace Server
#endif
BoolRes boolRes = new();
var gameID = communicationToGameID[request.PlayerId];
//boolRes.ActSuccess = game.Rescue(gameID);
var toGameID = communicationToGameID[request.ToPlayerId];
boolRes.ActSuccess = game.Rescue(gameID, toGameID);
return Task.FromResult(boolRes);
}
public override Task<BoolRes> StartTreatMate(TreatAndRescueMsg request, ServerCallContext context)
@@ -478,7 +479,8 @@ namespace Server
#endif
BoolRes boolRes = new();
var gameID = communicationToGameID[request.PlayerId];
//boolRes.ActSuccess = game.Treat(gameID);
var toGameID = communicationToGameID[request.ToPlayerId];
boolRes.ActSuccess = game.Treat(gameID, toGameID);
return Task.FromResult(boolRes);
}
public override Task<BoolRes> StartLearning(IDMsg request, ServerCallContext context)


+ 3
- 3
logic/Server/Program.cs View File

@@ -23,10 +23,10 @@ namespace Server
if (options == null)
{
Console.WriteLine("Argument parsing failed!");
// return 1;
return 1;
}

// Console.WriteLine("Server begins to run: " + options.ServerPort.ToString());
Console.WriteLine("Server begins to run: " + options.ServerPort.ToString());

try
{
@@ -34,7 +34,7 @@ namespace Server
Grpc.Core.Server server = new Grpc.Core.Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) })
{
Services = { AvailableService.BindService(gameServer) },
Ports = { new ServerPort("0.0.0.0", 8888, ServerCredentials.Insecure) }
Ports = { new ServerPort(options.ServerIP, options.ServerPort, ServerCredentials.Insecure) }
};
server.Start();



+ 1
- 1
logic/Server/Properties/launchSettings.json View File

@@ -2,7 +2,7 @@
"profiles": {
"Server": {
"commandName": "Project",
"commandLineArgs": "-p 8888 -t 2 -c 4"
"commandLineArgs": "--ip 0.0.0.0\r\n-p 8888\r\n-f playback\r\n-g 600\r\n-b true\r\n-c 4\r\n-t 2\r\n-n 1"
}
}
}

Loading…
Cancel
Save