Skip to content

Commit

Permalink
Merge pull request #123 from kinode-dao/hf/wk-jan-29-updates
Browse files Browse the repository at this point in the history
update http to add new WebSocketExt stuff
  • Loading branch information
nick1udwig authored Feb 13, 2024
2 parents e3ca99f + f1c571b commit e5de349
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/apis/http_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,46 @@ pub enum HttpServerAction {
path: String,
authenticated: bool,
encrypted: bool,
extension: bool,
},
/// SecureBind is the same as Bind, except that it forces new connections to be made
/// from the unique subdomain of the process that bound the path. These are *always*
/// authenticated. Since the subdomain is unique, it will require the user to be
/// logged in separately to the general domain authentication.
WebSocketSecureBind { path: String, encrypted: bool },
WebSocketSecureBind {
path: String,
encrypted: bool,
extension: bool,
},
/// Processes will RECEIVE this kind of request when a client connects to them.
/// If a process does not want this websocket open, they should issue a *request*
/// containing a [`type@HttpServerAction::WebSocketClose`] message and this channel ID.
WebSocketOpen { path: String, channel_id: u32 },
/// When sent, expects a lazy_load_blob containing the WebSocket message bytes to send.
WebSocketPush {
channel_id: u32,
message_type: WsMessageType,
},
/// When sent, expects a `lazy_load_blob` containing the WebSocket message bytes to send.
/// Modifies the `lazy_load_blob` by placing into `WebSocketExtPushData` with id taken from
/// this `KernelMessage` and `kinode_message_type` set to `desired_reply_type`.
WebSocketExtPushOutgoing {
channel_id: u32,
message_type: WsMessageType,
desired_reply_type: MessageType,
},
/// For communicating with the ext.
/// Kinode's http_server sends this to the ext after receiving `WebSocketExtPushOutgoing`.
/// Upon receiving reply with this type from ext, http_server parses, setting:
/// * id as given,
/// * message type as given (Request or Response),
/// * body as HttpServerRequest::WebSocketPush,
/// * blob as given.
WebSocketExtPushData {
id: u64,
kinode_message_type: MessageType,
blob: Vec<u8>,
},
/// Sending will close a socket the process controls.
WebSocketClose(u32),
}
Expand Down Expand Up @@ -165,3 +194,4 @@ pub struct HttpResponse {
This response is only required for HTTP requests.
`WebSocketOpen`, `WebSocketPush`, and `WebSocketClose` requests do not require a response.
If a process is meant to send data over an open WebSocket connection, it must issue a `HttpServerAction::WebSocketPush` request with the appropriate `channel_id`.
Find discussion of the `HttpServerAction::WebSocketExt*` requests in the [extensions document](../process/extensions.md).

0 comments on commit e5de349

Please sign in to comment.