namespace StudySystemClient.Request { public class Request { private Der.Datum datum; public Request(uint16 transaction_id, Body body) { datum = new Der.Sequence( { new Der.Integer(transaction_id), body.datum }); } public uint8[] encode() { return datum.encode(); } } public abstract class Body { protected enum Tag { PING = 0, LIST_ACTIVITIES = 1, LOG_SESSION = 2, } internal Der.Datum datum; protected Body(Tag tag, Der.Datum datum) { this.datum = new Der.Choice(tag, datum); } } public class Ping : Body { public Ping() { base(Tag.PING, new Der.Null()); } } public class ListActivities : Body { public ListActivities() { base(Tag.LIST_ACTIVITIES, new Der.Null()); } } public class LogSession : Body { public LogSession(string subject, ActivityType type, int64 timestamp, int minutes) { var fields = new Der.Datum[] { new Der.Utf8String(subject), new Der.Enumerated((int)type), new Der.Integer(timestamp), new Der.Integer(minutes), }; base(Tag.LOG_SESSION, new Der.Sequence(fields)); } } }