IExtension.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if !BESTHTTP_DISABLE_WEBSOCKET && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using BestHTTP.WebSocket.Frames;
  3. namespace BestHTTP.WebSocket.Extensions
  4. {
  5. public interface IExtension
  6. {
  7. /// <summary>
  8. /// This is the first pass: here we can add headers to the request to initiate an extension negotiation.
  9. /// </summary>
  10. /// <param name="request"></param>
  11. void AddNegotiation(HTTPRequest request);
  12. /// <summary>
  13. /// If the websocket upgrade succeded it will call this function to be able to parse the server's negotiation
  14. /// response. Inside this function the IsEnabled should be set.
  15. /// </summary>
  16. bool ParseNegotiation(WebSocketResponse resp);
  17. /// <summary>
  18. /// This function should return a new header flag based on the inFlag parameter. The extension should set only the
  19. /// Rsv1-3 bits in the header.
  20. /// </summary>
  21. byte GetFrameHeader(WebSocketFrame writer, byte inFlag);
  22. /// <summary>
  23. /// This function will be called to be able to transform the data that will be sent to the server.
  24. /// </summary>
  25. /// <param name="writer"></param>
  26. /// <returns></returns>
  27. byte[] Encode(WebSocketFrame writer);
  28. /// <summary>
  29. /// This function can be used the decode the server-sent data.
  30. /// </summary>
  31. byte[] Decode(byte header, byte[] data);
  32. }
  33. }
  34. #endif