-
Couldn't load subscription status.
- Fork 3
Server
George Michaelides edited this page Jul 3, 2020
·
12 revisions
var server = new GemServer(profile: "DefaultProfile",
new ServerConfig
{
Name = "MyServer",
Port = 14242,
EnableUPnP = false,
MaxConnections = 10,
Password = "1234",
ConnectionTimeout = 5.0f,
MaxConnectionAttempts = 5,
RequireAuthentication = true
},
PackageConfig.UDP);
server.RunAsync();
//...
//...
server.Disconnect();
OnIncomingConnection A client sends a connection approval message
OnClientDisconnect Someone disconnects
HandleNotifications A notification is received
GemSever.Profile("GemChat")
.OnIncomingConnection((server, connection, request)=>
{
request.Message == "please!!!" ?
connection.Approve() :
connection.Deny();
});
GemSever.Profile("GemChat")
.HandleNotifications((server, connection, notification)=>
{
if(notification.Message == "how are you?")
{
server.NotifyOnly(connection,"fine and you?")
}
});
Simply by decorating your POCO class with the [NetworkPackage("profile")] attribute
More info about network packages
GemServer
.RegisterCommand(command:"echo",
description:"Display Messages",
requiresAuthorization: false,
callback:(host, senderConnection, command,args)
=> host.SendToAll(args[0]));
GemServer.ExecuteCommand("echo i'm executing commands");
GemServer.ExecuteCommand(sender, "i'm remotely executing commands");