Empeld
Empeld plugin documentation.
essentials.Subsystems.Chat.ChatServer Class Reference
Inheritance diagram for essentials.Subsystems.Chat.ChatServer:
essentials.Subsystems.Chat.IChatServer pluginbase.Objects.Game.IServerSubsystem pluginbase.Objects.Game.ISubsystem

Public Member Functions

 ChatServer ()
 
void AddCommandHandler (IChatCommandHandler handler)
 
void ClearCommandHandlers ()
 
void OnStart ()
 
void OnStop ()
 
void Simulate (IFrameTimeState frameTime)
 
void BroadcastSystemMessage (string msg, params object[] args)
 
void SendDirectedMessage (ushort userId, string msg, params object[] args)
 
void SendDirectedMessage (IUser user, string msg, params object[] args)
 
void SendDirectedMessage (string username, string msg, params object[] args)
 

Protected Attributes

IRpcManager RpcManager
 
IUserManager UserManager
 
IPluginLogger Logger
 

Constructor & Destructor Documentation

◆ ChatServer()

essentials.Subsystems.Chat.ChatServer.ChatServer ( )
27  {
28  this.InjectDependencies();
29  this.RpcManager.RegisterClass(this);
30  _clientRpc = this.RpcManager.GetClass<ChatClient>();
31 
32  this.UserManager.OnJoin += OnPlayerJoin;
33  this.UserManager.OnLeave += OnPlayerLeave;
34 
35  AddCommandHandler(new UserManagerChatPlugin(this));
36  AddCommandHandler(new WorldChatPlugin(this));
37 
38  this.Logger.LogInfo("Chat server started");
39  }
IRpcManager RpcManager
Definition: ChatServer.cs:16
Action< IUser > OnJoin
Definition: IUserManager.cs:31
IPluginLogger Logger
Definition: ChatServer.cs:22
void AddCommandHandler(IChatCommandHandler handler)
Definition: ChatServer.cs:41
Action< IUser > OnLeave
Definition: IUserManager.cs:32
void LogInfo(string msg, params object[] args)
IUserManager UserManager
Definition: ChatServer.cs:19

Member Function Documentation

◆ AddCommandHandler()

void essentials.Subsystems.Chat.ChatServer.AddCommandHandler ( IChatCommandHandler  handler)
42  {
43  _chatCommandHandlers.Add(handler);
44  }

◆ BroadcastSystemMessage()

void essentials.Subsystems.Chat.ChatServer.BroadcastSystemMessage ( string  msg,
params object []  args 
)

Implements essentials.Subsystems.Chat.IChatServer.

71  {
72  BroadcastMessage(SERVER_USERNAME, UserAuthLevel.System, string.Format(msg, args));
73  }
UserAuthLevel
User authentication level
Definition: UserAuthLevel.cs:8

◆ ClearCommandHandlers()

void essentials.Subsystems.Chat.ChatServer.ClearCommandHandlers ( )
47  {
48  _chatCommandHandlers.Clear();
49  }

◆ OnStart()

void essentials.Subsystems.Chat.ChatServer.OnStart ( )

◆ OnStop()

void essentials.Subsystems.Chat.ChatServer.OnStop ( )

◆ SendDirectedMessage() [1/3]

void essentials.Subsystems.Chat.ChatServer.SendDirectedMessage ( ushort  userId,
string  msg,
params object []  args 
)

Implements essentials.Subsystems.Chat.IChatServer.

81  {
82  _clientRpc.Invoke("ChatMessage", RpcTarget.Client(userId), "SystemDirect", (int)UserAuthLevel.System, string.Format(msg, args));
83  }
UserAuthLevel
User authentication level
Definition: UserAuthLevel.cs:8
static RpcTarget Client(ushort id)
Create a target for a specific client
Definition: RpcTarget.cs:190
Class that specifies the target of an RPC class
Definition: RpcTarget.cs:21

◆ SendDirectedMessage() [2/3]

void essentials.Subsystems.Chat.ChatServer.SendDirectedMessage ( IUser  user,
string  msg,
params object []  args 
)

Implements essentials.Subsystems.Chat.IChatServer.

86  {
87  SendDirectedMessage(user.ClientIdent, msg, args);
88  }
void SendDirectedMessage(ushort userId, string msg, params object[] args)
Definition: ChatServer.cs:80
ushort ClientIdent
The Id of the user
Definition: IUser.cs:20

◆ SendDirectedMessage() [3/3]

void essentials.Subsystems.Chat.ChatServer.SendDirectedMessage ( string  username,
string  msg,
params object []  args 
)

Implements essentials.Subsystems.Chat.IChatServer.

91  {
92  var user = this.UserManager.GetUser(username);
93  if (user != null)
94  {
95  SendDirectedMessage(user, msg, args);
96  }
97  }
void SendDirectedMessage(ushort userId, string msg, params object[] args)
Definition: ChatServer.cs:80
IUserManager UserManager
Definition: ChatServer.cs:19

◆ Simulate()

void essentials.Subsystems.Chat.ChatServer.Simulate ( IFrameTimeState  frameTime)

Implements pluginbase.Objects.Game.ISubsystem.

58  { }

Member Data Documentation

◆ Logger

IPluginLogger essentials.Subsystems.Chat.ChatServer.Logger
protected

Attribute: Dependency

◆ RpcManager

IRpcManager essentials.Subsystems.Chat.ChatServer.RpcManager
protected

Attribute: Dependency

◆ UserManager

IUserManager essentials.Subsystems.Chat.ChatServer.UserManager
protected

Attribute: Dependency


The documentation for this class was generated from the following file: