private void OnCS_CloudSheet_GetRecords_Req(SecurePacketRequest reqPacket) { String filename = reqPacket.GetStringFromUtf16(); String sheetName = reqPacket.GetStringFromUtf16(); UInt32 startRowNo = reqPacket.GetUInt32(); SecurePacketResponse resPacket = new SecurePacketResponse(reqPacket, 65535); try { resPacket.ResultCodeNo = ResultCode.Ok; Workbook workbook = Workbooks.GetWorkbook(filename); SheetData sheet = workbook.GetSheetData(sheetName); Int32 hasMoreIdx = resPacket.PutByte(0); Int32 rowCountIdx = resPacket.PutInt32(0); Int32 rowCount = 0; UInt32 lastRowIndex = 0; foreach (Record data in sheet.Records) { if (data == null || data.RowNo < startRowNo) continue; ++rowCount; lastRowIndex = data.RowNo; resPacket.PutUInt32(data.RowNo); foreach (String value in data.DataList) { if (value == null) resPacket.PutStringAsUtf16(""); else resPacket.PutStringAsUtf16(value.ToString()); } // #! 대략 이쯤... 패킷 크기를 초과하지 않도록 적당이 끊어준다. if (resPacket.WrittenBytes > 50000) break; } resPacket.OverwriteByte(hasMoreIdx, (Byte)(lastRowIndex < sheet.MaxRowNo ? 1 : 0)); resPacket.OverwriteInt32(rowCountIdx, rowCount); } catch (AegisException e) { Logger.Write(LogType.Err, 2, e.ToString()); resPacket.Clear(); resPacket.ResultCodeNo = e.ResultCodeNo; } SendPacket(resPacket); }
private void OnCS_IMC_ChannelList_Req(SecurePacketRequest reqPacket) { SecurePacketResponse resPacket = new SecurePacketResponse(reqPacket, ResultCode.Ok, 4096); Int32 count = 0, idxCount; idxCount = resPacket.PutInt32(count); foreach (var channel in CastChannel.Channels) { resPacket.PutInt32(channel.ChannelNo); resPacket.PutStringAsUtf16(channel.Name); ++count; } resPacket.OverwriteInt32(idxCount, count); SendPacket(resPacket); }
private void OnCS_IMC_UserList_Req(SecurePacketRequest reqPacket) { SecurePacketResponse resPacket = new SecurePacketResponse(reqPacket, 4096); try { Int32 count = 0, idxCount; resPacket.ResultCodeNo = ResultCode.Ok; idxCount = resPacket.PutInt32(count); foreach (var user in _user.CastChannel.Users) { resPacket.PutInt32(user.UserNo); resPacket.PutStringAsUtf16(user.Profile.Nickname); ++count; } resPacket.OverwriteInt32(idxCount, count); } catch (AegisException e) { resPacket.ResultCodeNo = e.ResultCodeNo; } SendPacket(resPacket); }