-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from omnia-network/release/0.3.1
release/0.3.1
- Loading branch information
Showing
16 changed files
with
1,565 additions
and
1,208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module { | ||
/// The label used when constructing the certification tree. | ||
public let LABEL_WEBSOCKET : Blob = "websocket"; | ||
/// The default maximum number of messages returned by [ws_get_messages] at each poll. | ||
public let DEFAULT_MAX_NUMBER_OF_RETURNED_MESSAGES : Nat = 50; | ||
/// The default interval at which to send acknowledgements to the client. | ||
public let DEFAULT_SEND_ACK_INTERVAL_MS : Nat64 = 300_000; // 5 minutes | ||
/// The default timeout to wait for the client to send a keep alive after receiving an acknowledgement. | ||
public let DEFAULT_CLIENT_KEEP_ALIVE_TIMEOUT_MS : Nat64 = 60_000; // 1 minute | ||
|
||
/// The initial nonce for outgoing messages. | ||
public let INITIAL_OUTGOING_MESSAGE_NONCE : Nat64 = 0; | ||
/// The initial sequence number to expect from messages coming from clients. | ||
/// The first message coming from the client will have sequence number `1` because on the client the sequence number is incremented before sending the message. | ||
public let INITIAL_CLIENT_SEQUENCE_NUM : Nat64 = 1; | ||
/// The initial sequence number for outgoing messages. | ||
public let INITIAL_CANISTER_SEQUENCE_NUM : Nat64 = 0; | ||
|
||
/// The number of messages to delete from the outgoing messages queue every time a new message is added. | ||
public let MESSAGES_TO_DELETE_COUNT : Nat = 5; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import Principal "mo:base/Principal"; | ||
import Nat64 "mo:base/Nat64"; | ||
|
||
import Types "Types"; | ||
|
||
module { | ||
public type WsError = { | ||
#AnonymousPrincipalNotAllowed; | ||
#ClientKeyAlreadyConnected : { | ||
client_key : Types.ClientKey; | ||
}; | ||
#ClientKeyMessageMismatch : { | ||
client_key : Types.ClientKey; | ||
}; | ||
#ClientKeyNotConnected : { | ||
client_key : Types.ClientKey; | ||
}; | ||
#ClientNotRegisteredToGateway : { | ||
client_key : Types.ClientKey; | ||
gateway_principal : Types.GatewayPrincipal; | ||
}; | ||
#ClientPrincipalNotConnected : { | ||
client_principal : Types.ClientPrincipal; | ||
}; | ||
#DecodeServiceMessageContent : { | ||
err : Text; | ||
}; | ||
#ExpectedIncomingMessageToClientNumNotInitialized : { | ||
client_key : Types.ClientKey; | ||
}; | ||
#GatewayNotRegistered : { | ||
gateway_principal : Types.GatewayPrincipal; | ||
}; | ||
#InvalidServiceMessage; | ||
#IncomingSequenceNumberWrong : { | ||
expected_sequence_num : Nat64; | ||
actual_sequence_num : Nat64; | ||
}; | ||
#OutgoingMessageToClientNumNotInitialized : { | ||
client_key : Types.ClientKey; | ||
}; | ||
}; | ||
|
||
public func to_string(err : WsError) : Text { | ||
switch (err) { | ||
case (#AnonymousPrincipalNotAllowed) { | ||
"Anonymous principal is not allowed"; | ||
}; | ||
case (#ClientKeyAlreadyConnected({ client_key })) { | ||
"Client with key " # Types.clientKeyToText(client_key) # " already has an open connection"; | ||
}; | ||
case (#ClientKeyMessageMismatch({ client_key })) { | ||
"Client with principal " # Principal.toText(client_key.client_principal) # " has a different key than the one used in the message"; | ||
}; | ||
case (#ClientKeyNotConnected({ client_key })) { | ||
"Client with key " # Types.clientKeyToText(client_key) # " doesn't have an open connection"; | ||
}; | ||
case (#ClientNotRegisteredToGateway({ client_key; gateway_principal })) { | ||
"Client with key " # Types.clientKeyToText(client_key) # " was not registered to gateway " # Principal.toText(gateway_principal); | ||
}; | ||
case (#ClientPrincipalNotConnected({ client_principal })) { | ||
"Client with principal " # Principal.toText(client_principal) # " doesn't have an open connection"; | ||
}; | ||
case (#DecodeServiceMessageContent({ err })) { | ||
"Error decoding service message content: " # err; | ||
}; | ||
case (#ExpectedIncomingMessageToClientNumNotInitialized({ client_key })) { | ||
"Expected incoming message to client num not initialized for client key " # Types.clientKeyToText(client_key); | ||
}; | ||
case (#GatewayNotRegistered({ gateway_principal })) { | ||
"Gateway with principal " # Principal.toText(gateway_principal) # " is not registered"; | ||
}; | ||
case (#InvalidServiceMessage) { | ||
"Invalid service message"; | ||
}; | ||
case (#IncomingSequenceNumberWrong({ expected_sequence_num; actual_sequence_num })) { | ||
"Expected incoming sequence number " # Nat64.toText(expected_sequence_num) # " but got " # Nat64.toText(actual_sequence_num); | ||
}; | ||
case (#OutgoingMessageToClientNumNotInitialized({ client_key })) { | ||
"Outgoing message to client num not initialized for client key " # Types.clientKeyToText(client_key); | ||
}; | ||
}; | ||
}; | ||
|
||
public func to_string_result(err : WsError) : Types.Result<(), Text> { | ||
#Err(to_string(err)); | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.