Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Library code
- mutable struct aws_mqtt_connection_options
- host_name::aws_byte_cursor
- port::UInt16
- socket_options::Ptr{aws_socket_options}
- tls_options::Ptr{aws_tls_connection_options}
- client_id::aws_byte_cursor
- keep_alive_time_secs::UInt16
- ping_timeout_ms::UInt32
- protocol_operation_timeout_ms::UInt32
- on_connection_complete::Ptr{Cvoid}
- user_data::Ptr{Cvoid}
- clean_session::Bool
- end
- """
- aws_mqtt_client_connection_connect(connection, connection_options)
- 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.
- ### Parameters
- * `connection`:\\[in\\] The connection object
- * `connection_options`:\\[in\\] Configuration information for the connection attempt
- ### Returns
- [`AWS_OP_SUCCESS`](@ref) if the connection has been successfully initiated, otherwise [`AWS_OP_ERR`](@ref) and [`aws_last_error`](@ref)() will be set.
- ### Prototype
- ```c
- int aws_mqtt_client_connection_connect( mutable struct aws_mqtt_client_connection *connection, const mutable struct aws_mqtt_connection_options *connection_options);
- ```
- """
- function aws_mqtt_client_connection_connect(connection, connection_options)
- ccall((:aws_mqtt_client_connection_connect, libawsmqtt), Cint, (Ptr{aws_mqtt_client_connection}, Ptr{aws_mqtt_connection_options}), connection, connection_options)
- end
- # Test code
- conn_options = Ref(aws_mqtt_connection_options(
- host_name_cur[],
- UInt16(8883),
- Base.unsafe_convert(Ptr{aws_socket_options}, socket_options),
- Base.unsafe_convert(Ptr{aws_tls_connection_options}, tls_connection_options),
- client_id_cur[],
- 0,
- 0,
- 0,
- C_NULL, # on_connection_complete # TODO
- C_NULL, # user_data
- true
- ))
- @show conn_options
- @show Base.unsafe_convert(Ptr{aws_mqtt_connection_options}, conn_options)
- aws_mqtt_client_connection_connect(connection, conn_options)
- # The rr output
- (rr) c
- Continuing.
- host_name_cur = Base.RefValue{aws_byte_cursor}(aws_byte_cursor(0x000000000000002e, Ptr{UInt8} @0x00007f7314c1f218))
- 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))
- Base.unsafe_convert(Ptr{aws_mqtt_connection_options}, conn_options) = Ptr{aws_mqtt_connection_options} @0x00007f7311699cf0
- [New Thread 208159.208171]
- [New Thread 208159.208231]
- 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
- warning: Source file is more recent than executable.
- 1377 AWS_LOGF_TRACE(AWS_LS_MQTT_CLIENT, "id=%p: Opening connection", (void *)connection);
- (rr) p *connection_options
- $1 = {host_name = {len = 140132226638704, ptr = 0x7f73066522b3 <jl_system_image_data+28787> "\006s\177"}, port = 54560, socket_options = 0x7ffff3c5d540, tls_options = 0x7f73140369b0, client_id = {
- 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