This is a example of a 317 server using the Netscape Framework. To see NetScape go here: https://github.com/JayArrowz/NetScape
Config exists inside appsettings.json. Ensure you have the correct ConnectionStrings to the postgres database
Run the command at the root of the repo:
dotnet tool install -g dotnet-ef
dotnet ef migrations add InitialCreate
dotnet ef database update
Create the folder AspNetServerData\Cache
in your users home folder and add the cache
This can be changed via the appsettings.json
Currently this example uses the 317 modules. There are other revision specific modules available on Nuget to replace these ones.
List<Module> modules = new()
{
new ThreeOneSevenGameModule(),
new MessagesModule(
typeof(ThreeOneSevenEncoderMessages.Types),
typeof(ThreeOneSevenDecoderMessages.Types)
),
new ThreeOneSevenLoginModule(),
new ThreeOneSevenUpdatingModule()
};
ServerHandler.RunServer<MyPlayer>("appsettings.json", BuildDbOptions, modules);
Console.ReadLine();
A user can either use the default Player object or create their own by extending it. A example is shown here:
public class MyPlayer : Player
{
public string ANewFieldInDb { get; set; }
}
ServerHandler.RunServer<MyPlayer>("appsettings.json", BuildDbOptions, modules);
Whenever a new field has been added to the player a new migration has to be created and the database has to be updated by running the following commands:
dotnet ef migrations add NewMigrationName
dotnet ef database update
A example message handler can be seen here, the server automatically detects these annotations across the whole solution:
[MessageHandler]
public class TestButtonHandler
{
[Message(typeof(ThreeOneSevenDecoderMessages.Types.ButtonMessage))]
public void DoSomeShit(DecoderMessage<ThreeOneSevenDecoderMessages.Types.ButtonMessage> message)
{
Console.WriteLine("Button clicked: " + message.Message.InterfaceId);
}
}