Admins can get a list of the StationEvents (#1670)
* -GetStationEventsMsg -Fixed random in events help * Don't send on connect * Delete StationEvents on disconnect * Resolve IClientNetManager when needed * :smilethink: * Remove setter * Removed unused imports * Don't resolve twice * Add Event
This commit is contained in:
46
Content.Shared/StationEvents/SharedStationEvent.cs
Normal file
46
Content.Shared/StationEvents/SharedStationEvent.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Lidgren.Network;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Content.Shared.StationEvents
|
||||
{
|
||||
public class SharedStationEvent
|
||||
{
|
||||
public class MsgGetStationEvents : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgGetStationEvents);
|
||||
public MsgGetStationEvents(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
public List<string> Events;
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
||||
var length = buffer.ReadVariableInt32();
|
||||
using var stream = buffer.ReadAsStream(length);
|
||||
Events = serializer.Deserialize<List<string>>(stream);
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
serializer.Serialize(stream, Events);
|
||||
buffer.WriteVariableInt32((int)stream.Length);
|
||||
stream.TryGetBuffer(out var segment);
|
||||
buffer.Write(segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user