mirror of
https://github.com/AlexMacocian/MTSC.git
synced 2026-07-25 08:22:17 +00:00
56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace MTSC.Server.Handlers
|
|
{
|
|
/// <summary>
|
|
/// Broadcast handler.
|
|
/// </summary>
|
|
public class BroadcastHandler : IHandler
|
|
{
|
|
private Server managedServer;
|
|
|
|
public BroadcastHandler(Server server)
|
|
{
|
|
this.managedServer = server;
|
|
}
|
|
|
|
public void ClientRemoved(ClientStruct client)
|
|
{
|
|
|
|
}
|
|
|
|
public bool HandleClient(ClientStruct client)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public bool HandleReceivedMessage(ClientStruct client, Message message)
|
|
{
|
|
managedServer.Log("Broadcast: " + ASCIIEncoding.ASCII.GetString(message.MessageBytes));
|
|
managedServer.Log("From: " + client.TcpClient.Client.RemoteEndPoint.ToString());
|
|
foreach(ClientStruct clientStruct in managedServer.Clients)
|
|
{
|
|
managedServer.QueueMessage(clientStruct, message.MessageBytes);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool HandleSendMessage(ClientStruct client, ref Message message)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public bool PreHandleReceivedMessage(ClientStruct client, ref Message message)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public void Tick()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|