-
Notifications
You must be signed in to change notification settings - Fork 3
Server
George Michaelides edited this page Mar 25, 2015
·
12 revisions
###Start / Close a server
var server = new GemServer(ProfileName: "GemProfile"
ServerName: "GemServer",
Port: 14242,
MaxConnections: 10,
Password: "123456"
RequirePassword: true );
server.RunAsync();
//...
//...
server.Disconnect();
###Configure Behavior
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?")
}
});
###Send Messages via Network Package
Simply by decorating your POCO class with the [NetworkPackage("profile")] attribute
More info about network packages
###Register a command
GemServer
.RegisterCommand(command:"echo",
description:"Display Messages",
requiresAuthorization: false,
callback:(host, senderConnection, command,args)
=> host.SendToAll(args[0]));
###Execute a Command
GemServer.ExecuteCommand("echo i'm executing commands");
GemServer.ExecuteCommand(sender, "i'm remotely executing commands");