mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-05 06:00:29 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
70
server/FSO.Server.Protocol/Electron/Packets/MailRequest.cs
Executable file
70
server/FSO.Server.Protocol/Electron/Packets/MailRequest.cs
Executable file
|
@ -0,0 +1,70 @@
|
|||
using FSO.Common.Serialization;
|
||||
using FSO.Files.Formats.tsodata;
|
||||
using Mina.Core.Buffer;
|
||||
using System.IO;
|
||||
|
||||
namespace FSO.Server.Protocol.Electron.Packets
|
||||
{
|
||||
public class MailRequest : AbstractElectronPacket
|
||||
{
|
||||
public MailRequestType Type;
|
||||
public long TimestampID;
|
||||
public MessageItem Item;
|
||||
|
||||
public override void Deserialize(IoBuffer input, ISerializationContext context)
|
||||
{
|
||||
Type = input.GetEnum<MailRequestType>();
|
||||
if (Type == MailRequestType.SEND) {
|
||||
var length = input.GetInt32();
|
||||
var dat = new byte[length];
|
||||
for (int i=0; i<length; i++)
|
||||
{
|
||||
dat[i] = input.Get();
|
||||
}
|
||||
|
||||
using (var str = new MemoryStream(dat))
|
||||
{
|
||||
Item = new MessageItem(str);
|
||||
|
||||
}
|
||||
} else
|
||||
{
|
||||
TimestampID = input.GetInt64();
|
||||
}
|
||||
}
|
||||
|
||||
public override ElectronPacketType GetPacketType()
|
||||
{
|
||||
return ElectronPacketType.MailRequest;
|
||||
}
|
||||
|
||||
public override void Serialize(IoBuffer output, ISerializationContext context)
|
||||
{
|
||||
output.PutEnum(Type);
|
||||
if (Type == MailRequestType.SEND)
|
||||
{
|
||||
byte[] dat;
|
||||
if (Item == null) dat = new byte[0];
|
||||
else
|
||||
{
|
||||
using (var str = new MemoryStream())
|
||||
{
|
||||
Item.Save(str);
|
||||
dat = str.ToArray();
|
||||
}
|
||||
}
|
||||
output.PutInt32(dat.Length);
|
||||
foreach (var b in dat)
|
||||
output.Put(b);
|
||||
} else
|
||||
output.PutInt64(TimestampID);
|
||||
}
|
||||
}
|
||||
|
||||
public enum MailRequestType : byte
|
||||
{
|
||||
POLL_INBOX,
|
||||
SEND,
|
||||
DELETE
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue