Advertisement
Guest User

Untitled

a guest
Apr 12th, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. # Library code
  2. mutable struct aws_mqtt_connection_options
  3. host_name::aws_byte_cursor
  4. port::UInt16
  5. socket_options::Ptr{aws_socket_options}
  6. tls_options::Ptr{aws_tls_connection_options}
  7. client_id::aws_byte_cursor
  8. keep_alive_time_secs::UInt16
  9. ping_timeout_ms::UInt32
  10. protocol_operation_timeout_ms::UInt32
  11. on_connection_complete::Ptr{Cvoid}
  12. user_data::Ptr{Cvoid}
  13. clean_session::Bool
  14. end
  15.  
  16. """
  17. aws_mqtt_client_connection_connect(connection, connection_options)
  18.  
  19. Opens the actual connection defined by [`aws_mqtt_client_connection_new`](@ref). Once the connection is opened, on\\_connack will be called. Only called when connection is disconnected.
  20.  
  21. ### Parameters
  22. * `connection`:\\[in\\] The connection object
  23. * `connection_options`:\\[in\\] Configuration information for the connection attempt
  24. ### Returns
  25. [`AWS_OP_SUCCESS`](@ref) if the connection has been successfully initiated, otherwise [`AWS_OP_ERR`](@ref) and [`aws_last_error`](@ref)() will be set.
  26. ### Prototype
  27. ```c
  28. int aws_mqtt_client_connection_connect( mutable struct aws_mqtt_client_connection *connection, const mutable struct aws_mqtt_connection_options *connection_options);
  29. ```
  30. """
  31. function aws_mqtt_client_connection_connect(connection, connection_options)
  32. ccall((:aws_mqtt_client_connection_connect, libawsmqtt), Cint, (Ptr{aws_mqtt_client_connection}, Ptr{aws_mqtt_connection_options}), connection, connection_options)
  33. end
  34.  
  35.  
  36. # Test code
  37. conn_options = Ref(aws_mqtt_connection_options(
  38. host_name_cur[],
  39. UInt16(8883),
  40. Base.unsafe_convert(Ptr{aws_socket_options}, socket_options),
  41. Base.unsafe_convert(Ptr{aws_tls_connection_options}, tls_connection_options),
  42. client_id_cur[],
  43. 0,
  44. 0,
  45. 0,
  46. C_NULL, # on_connection_complete # TODO
  47. C_NULL, # user_data
  48. true
  49. ))
  50.  
  51. @show conn_options
  52. @show Base.unsafe_convert(Ptr{aws_mqtt_connection_options}, conn_options)
  53. aws_mqtt_client_connection_connect(connection, conn_options)
  54.  
  55.  
  56. # The rr output
  57. (rr) c
  58. Continuing.
  59. host_name_cur = Base.RefValue{aws_byte_cursor}(aws_byte_cursor(0x000000000000002e, Ptr{UInt8} @0x00007f7314c1f218))
  60. conn_options = Base.RefValue{aws_mqtt_connection_options}(aws_mqtt_connection_options(aws_byte_cursor(0x000000000000002e, Ptr{UInt8} @0x00007f7314c1f218), 0x22b3, Ptr{aws_socket_options} @0x00007ffff3c5d520, Ptr{aws_tls_connection_options} @0x00007ffff3c5d540, aws_byte_cursor(0x000000000000000e, Ptr{UInt8} @0x00007f7314c14938), 0x0000, 0x00000000, 0x00000000, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000, true))
  61. Base.unsafe_convert(Ptr{aws_mqtt_connection_options}, conn_options) = Ptr{aws_mqtt_connection_options} @0x00007f7311699cf0
  62. [New Thread 208159.208171]
  63. [New Thread 208159.208231]
  64.  
  65. Thread 1 hit Breakpoint 1, aws_mqtt_client_connection_connect (connection=0x1ef4e90, connection_options=0x7f7311699cf0) at /workspace/srcdir/aws-c-mqtt/source/client.c:1377
  66. warning: Source file is more recent than executable.
  67. 1377 AWS_LOGF_TRACE(AWS_LS_MQTT_CLIENT, "id=%p: Opening connection", (void *)connection);
  68. (rr) p *connection_options
  69. $1 = {host_name = {len = 140132226638704, ptr = 0x7f73066522b3 <jl_system_image_data+28787> "\006s\177"}, port = 54560, socket_options = 0x7ffff3c5d540, tls_options = 0x7f73140369b0, client_id = {
  70. len = 108789760, ptr = 0x0}, keep_alive_time_secs = 0, ping_timeout_ms = 0, protocol_operation_timeout_ms = 0, on_connection_complete = 0x1, user_data = 0x0, clean_session = false}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement