ByteQueue.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* ----------------------------------------------------------------------------
  2. * This file was automatically generated by SWIG (http://www.swig.org).
  3. * Version 2.0.1
  4. *
  5. * Do not make changes to this file unless you know what you are doing--modify
  6. * the SWIG interface file instead.
  7. * ----------------------------------------------------------------------------- */
  8. namespace RakNet {
  9. using System;
  10. using System.Runtime.InteropServices;
  11. public class ByteQueue : IDisposable {
  12. private HandleRef swigCPtr;
  13. protected bool swigCMemOwn;
  14. internal ByteQueue(IntPtr cPtr, bool cMemoryOwn) {
  15. swigCMemOwn = cMemoryOwn;
  16. swigCPtr = new HandleRef(this, cPtr);
  17. }
  18. internal static HandleRef getCPtr(ByteQueue obj) {
  19. return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  20. }
  21. ~ByteQueue() {
  22. Dispose();
  23. }
  24. public virtual void Dispose() {
  25. lock(this) {
  26. if (swigCPtr.Handle != IntPtr.Zero) {
  27. if (swigCMemOwn) {
  28. swigCMemOwn = false;
  29. RakNetPINVOKE.delete_ByteQueue(swigCPtr);
  30. }
  31. swigCPtr = new HandleRef(null, IntPtr.Zero);
  32. }
  33. GC.SuppressFinalize(this);
  34. }
  35. }
  36. public byte[] PeekContiguousBytes(out uint outLength)
  37. {
  38. return PeekContiguousBytesHelper(out outLength);
  39. }
  40. public ByteQueue() : this(RakNetPINVOKE.new_ByteQueue(), true) {
  41. }
  42. public uint GetBytesWritten() {
  43. uint ret = RakNetPINVOKE.ByteQueue_GetBytesWritten(swigCPtr);
  44. return ret;
  45. }
  46. public void IncrementReadOffset(uint length) {
  47. RakNetPINVOKE.ByteQueue_IncrementReadOffset(swigCPtr, length);
  48. }
  49. public void DecrementReadOffset(uint length) {
  50. RakNetPINVOKE.ByteQueue_DecrementReadOffset(swigCPtr, length);
  51. }
  52. public void Clear(string file, uint line) {
  53. RakNetPINVOKE.ByteQueue_Clear(swigCPtr, file, line);
  54. }
  55. public void Print() {
  56. RakNetPINVOKE.ByteQueue_Print(swigCPtr);
  57. }
  58. public void WriteBytes(byte[] inByteArray, uint length, string file, uint line) {
  59. RakNetPINVOKE.ByteQueue_WriteBytes(swigCPtr, inByteArray, length, file, line);
  60. }
  61. public bool ReadBytes(byte[] inOutByteArray, uint maxLengthToRead, bool peek) {
  62. bool ret = RakNetPINVOKE.ByteQueue_ReadBytes(swigCPtr, inOutByteArray, maxLengthToRead, peek);
  63. return ret;
  64. }
  65. private byte[] PeekContiguousBytesHelper(out uint outLength)
  66. {
  67. IntPtr cPtr = RakNetPINVOKE.ByteQueue_PeekContiguousBytesHelper(swigCPtr, out outLength);
  68. int len = (int)outLength;
  69. if (len <= 0)
  70. {
  71. return null;
  72. }
  73. byte[] returnBytes = new byte[len];
  74. Marshal.Copy(cPtr, returnBytes, 0, len);
  75. return returnBytes;
  76. }
  77. }
  78. }
粤ICP备19079148号