public static void WriteCommand(this IPCWriter writer, ICommand command) { CommandType type; switch (command) { case Execute _: type = CommandType.Execute; break; case FetchMetadata _: type = CommandType.FetchMetadata; break; case FetchResultRange _: type = CommandType.FetchResultRange; break; case Deploy _: type = CommandType.Deploy; break; case ListEnvironmentVariables _: type = CommandType.ListEnvironmentVariables; break; case PutFileCommand _: type = CommandType.PutFile; break; case PutDirectoryCommand _: type = CommandType.PutDirectory; break; case ListFilesCommand _: type = CommandType.ListFiles; break; case GetFilesCommand _: type = CommandType.GetFiles; break; case GetServerCapabilitiesCommand _: type = CommandType.GetServerCapabilities; break; case ExecutionTimedOutActionCommand _: type = CommandType.ExecutionTimedOutAction; break; case CompressedCommand _: type = CommandType.CompressedCommand; break; default: throw new ArgumentException($"Unable to serialize {command.GetType()}"); } writer.Write((byte)type); command.Serialize(writer); }
void GetChannels(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var channels = sync.GetAllChannels(); var packet = new IPCWriter(IPC.ChannelList); packet.Write(channels.Count); // server count foreach (var server in channels) { packet.Write((int)server.Key); // server id packet.Write(server.Value.Count); // channel count foreach (var channel in server.Value) { packet.Write(channel.Value.id); packet.Write(channel.Value.type); packet.Write((int)channel.Value.ip); packet.Write(channel.Value.port); packet.Write(channel.Value.maxPlayers); packet.Write(channel.Value.curPlayers); } } receiver.Send(packet); }
public static void WriteResponse(this IPCWriter writer, IResponse response) { ResponseType type; switch (response) { case ExecutionCompleted _: type = ResponseType.ExecutionCompleted; break; case MetadataFetched _: type = ResponseType.MetadataFetched; break; case ResultRangeFetched _: type = ResponseType.ResultRangeFetched; break; case EnvironmentVariablesListed _: type = ResponseType.EnvironmentVariablesListed; break; case PutFileResponse _: type = ResponseType.PutFile; break; case PutDirectoryResponse _: type = ResponseType.PutDirectory; break; case ListFilesResponse _: type = ResponseType.ListFiles; break; case GetFilesResponse _: type = ResponseType.GetFiles; break; case GetServerCapabilitiesResponse _: type = ResponseType.GetServerCapabilities; break; case ExecutionTimedOutResponse _: type = ResponseType.ExecutionTimedOut; break; case ExecutionTerminatedResponse _: type = ResponseType.ExecutionTerminated; break; case CompressedResponse _: type = ResponseType.CompressedResponse; break; default: throw new ArgumentException($"Unable to serialize {response.GetType()}"); } writer.Write((byte)type); response.Serialize(writer); }
public void Serialize(IPCWriter writer) { writer.Write(WorkingDirectory); writer.Write(Executable); writer.Write(Arguments); writer.Write(RunAsAdministrator); writer.Write(ExecutionTimeoutSecs); }
public void Serialize(IPCWriter writer) { writer.WriteLengthPrefixedArray(FilePath); writer.Write(BinaryOutput); writer.Write(ByteOffset); writer.Write(ByteCount); writer.Write(OutputOffset); }
public void Serialize(IPCWriter writer) { writer.Write7BitEncodedInt(ExtensionCapabilities.Count); foreach (var cap in ExtensionCapabilities) { writer.Write((byte)cap); } }
public void Serialize(IPCWriter writer) { writer.Write((byte)Status); writer.Write(ExitCode); writer.Write(Stdout); writer.Write(Stderr); writer.Write(ExecutionTime); }
public void Serialize(IPCWriter writer) { writer.Write7BitEncodedInt(Files.Length); foreach (var file in Files) { writer.Write(file.RelativePath); writer.Write(file.Size); writer.Write(file.LastWriteTimeUtc); } }
public void Serialize(IPCWriter writer) { using (var outputStream = new MemoryStream()) { using (var dstream = new DeflateStream(outputStream, CompressionLevel.Optimal)) using (var compressedWriter = new IPCWriter(dstream)) compressedWriter.WriteResponse(InnerResponse); writer.WriteLengthPrefixedBlob(outputStream.ToArray()); } }
void GetUser(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var magic = data.ReadUInt64(); var packet = new IPCWriter(IPC.GetUser); if (!sync.UserExists(magic)) { packet.Write(-1); receiver.Send(packet); return; } var id = sync.GetUser(magic); packet.Write(id); receiver.Send(packet); }
public void Serialize(IPCWriter writer) { writer.Write(TerminateProcesses); }
public void Serialize(IPCWriter writer) { writer.Write(Path); writer.Write(IncludeSubdirectories); }
public void Serialize(IPCWriter writer) => Info.Serialize(writer);
public void Serialize(IPCWriter writer) => writer.WriteLengthPrefixedArray(TerminatedProcessTree);
public void Serialize(IPCWriter writer) { writer.Write((byte)Status); writer.WriteLengthPrefixedArray(Files); }
public void Serialize(IPCWriter writer) => writer.WriteLengthPrefixedDict(Variables);
public void Serialize(IPCWriter writer) { writer.Write((byte)Status); }
public void Serialize(IPCWriter writer) { writer.WriteLengthPrefixedBlob(Data); writer.Write(Destination); }
public void Serialize(IPCWriter writer) { writer.Write(ByteCount); writer.Write(Timestamp); writer.Write((byte)Status); }
public void Serialize(IPCWriter writer) { writer.WriteLengthPrefixedBlob(Data); writer.Write(Timestamp); writer.Write((byte)Status); }
public void Serialize(IPCWriter writer) { writer.Write(UseCompression); writer.Write(RootPath); writer.WriteLengthPrefixedArray(Paths); }
public void Serialize(IPCWriter writer) { writer.WriteLengthPrefixedBlob(Data); writer.Write(Path); writer.Write(WorkDir); }
public void Serialize(IPCWriter _) { }
void HeartBeat(IPCReceiver receiver, IPCReader data, SyncHandler sync) { var packet = new IPCWriter(IPC.HeartBeat); receiver.Send(packet); }
public void Serialize(IPCWriter writer) { writer.WriteLengthPrefixedArray(Files); writer.Write(Path); writer.Write(PreserveTimestamps); }