Skip to content

Instantly share code, notes, and snippets.

@mathewmoon
Created August 2, 2019 17:16
Show Gist options
  • Save mathewmoon/e9028a90078886935b2b9d6dcc2fc9b1 to your computer and use it in GitHub Desktop.
Save mathewmoon/e9028a90078886935b2b9d6dcc2fc9b1 to your computer and use it in GitHub Desktop.
##########################
#
# Client session flow
#
##########################
#send
[
1, #HELLO
"com.myrealm",
{
"agent": "echostreams-python-client-1.0.1",
"roles": {
"publisher": {},
"subscriber": {}
},
"authmethods": ["wampcra"],
"authid": <username>
}
]
#broker sends a CHALLENGE for authentication
[
4, # CHALLENGE
"wampcra", # CHALLENGE type
{ # The actual challenge string
"challenge": "{
\"nonce\": \"LHRTC9zeOIrt_9U3\",
\"authprovider\": \"userdb\",
\"authid\": \"<username>\",
\"timestamp\": \"2014-06-22T16:36:25.448Z\",
\"authrole\": \"<role>\",
\"authmethod\": \"wampcra\",
\"session\": 3251278072152162
}",
"salt": "salt123",
"keylen": 32,
"iterations": 1000
}
]
# client sends AUTHENTICATE response
[
5, # AUTHENTICATE
base64(HMAC[SHA256]_{secret} (challenge)),
{}
]
#broker sends a WELCOME
[
2, #WELCOME
<session id>,
{
"authid": <username>,
"authrole": <role>,
"authmethod": "wampcra",
"authprovider": "userdb",
"agent": "echostreams-broker-1.1.1",
"roles": { # Features that this router supports eg: broker | dealer | both
"broker": { "challenge-response authentication": true } # Features that the broker provides
}
}
]
#broker receive on client error or client receive on broker error
[
3, #ABORT
{"message": "The realm does not exist."},
"wamp.error.no_such_realm" # URI for error
]
#client sends to disconnect
[
6, #GOODBYE
{}, # Message contains the reason for disconnecting
"wamp.close.close_realm"
]
#broker replies
[
6, #GOODBY
{}, # Message contains the reason for disconnecting
"wamp.close.goodbye_and_out"
]
#OR
#broker wants to disconnect for some reason
[
6, #GOODBY
{"message": "Broker shutting down"}, # Message contains the reason for disconnecting
"wamp.close.system_shutdown"
]
#client replies
[
6, #GOODBY
{}, # Message contains the reason for disconnecting
"wamp.close.goodbye_and_out"
]
###########################
#
# Client subscribe flow
#
##########################
# client send request to SUBSCRIBE to topic
[
32, # SUBSCRIBE
123456, # Client generates request ID
{ # Custom attributes that we use
"filter": "<dynamodb_filter_expression>",
"type": "exclusive|shared|failover"
},
com.realm.topic
]
# broker send ack to SUBSCRIBE
[
33, # SUBSCRIBED
123456, # MUST be id from subscribe request
567 # SUBSCRIPTION ID generated by the broker
]
#broker send EVENT, which is our message
[EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list, PUBLISH.ArgumentKw|dict]
[
36, # EVENT
567, # SUBSCRIPTION ID that was returned in SUBSCRIBED
123, # PUBLICATION ID of the EVENT
{}, # Details
[], # Could be used for our message
{ message.... } # Ideal place for our message to be put by the PUBLISHER
]
# client send request to UNSUBSCRIBE from topic
[
34, # UNSUBSCRIBE
1234567, # Generated by client
567 # SUBSCRIPTION ID
]
# broker send ack to UNSUBSCRIBE
[
35, #UNSUBSCRIBED
1234567 # Original REQUEST ID for the client's UNSUBSCRIBE
]
#####################
#
# Client publish flow
#
#####################
#client send an EVENT or "message"
[
16, # PUBLISH
12345678, # REQUEST ID generated by the publisher
{"acknowledge": true}, # acknowledge is optional
com.realm.topic, # TOPIC to publish to
[], # List sent as payload. Could be used for the message
{ message...} # The ideal place for us to expect the message
]
#broker acks with PUBLISHED only if acknowledge == true in the client's args for the PUBLISH that it just sent
[
17, # PUBLISHED
12345678, # REQUEST ID from the PUBLISH that we are ack'ing
123 # PUBLICATION ID genearated by the broker
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment