private uint _maxChunkSize = 1048576; //1MB public override void HandleMcpeResourcePackChunkRequest(McpeResourcePackChunkRequest message) { var chunk = _plugin.ResourcePackProvider.GetResourcePackChunk(message.packageId, message.chunkIndex, _maxChunkSize); McpeResourcePackChunkData chunkData = McpeResourcePackChunkData.CreateObject(); chunkData.packageId = message.packageId; chunkData.chunkIndex = message.chunkIndex; chunkData.progress = (_maxChunkSize * message.chunkIndex); //chunkData.length = (uint) chunk.Length; chunkData.payload = chunk; SendPacket(chunkData); }
public override void HandleMcpeResourcePackChunkData(McpeResourcePackChunkData message) { string fileName = Path.GetTempPath() + "ResourcePackChunkData_" + message.packageId + ".zip"; Log.Warn("Writing ResourcePackChunkData part " + message.chunkIndex.ToString() + " to filename: " + fileName); FileStream file = File.OpenWrite(fileName); file.Seek((long)message.progress, SeekOrigin.Begin); file.Write(message.payload, 0, message.payload.Length); file.Close(); Log.Debug($"packageId={message.packageId}"); Log.Debug($"unknown1={message.chunkIndex}"); Log.Debug($"unknown3={message.progress}"); Log.Debug($"Actual Lenght={message.payload.Length}"); base.HandleMcpeResourcePackChunkData(message); }
public virtual void HandleMcpeResourcePackChunkData(McpeResourcePackChunkData message) { if (message.chunkIndex + 1 < _resourcePackDataInfos[message.packageId]) { var request = new McpeResourcePackChunkRequest(); request.packageId = message.packageId; request.chunkIndex = message.chunkIndex + 1; Client.SendPacket(request); } else { _resourcePackDataInfos.Remove(message.packageId); } if (_resourcePackDataInfos.Count == 0) { var response = new McpeResourcePackClientResponse(); response.responseStatus = 3; Client.SendPacket(response); } }