#telnet #actor #api-bindings #capability-provider

wasmcloud-actor-telnet

Actor interface for the wasmCloud telnet capability provider

4 releases

0.2.0 Apr 6, 2021
0.1.2 Mar 23, 2021
0.1.1 Feb 17, 2021
0.1.0 Feb 10, 2021

#1594 in WebAssembly


Used in wasmcloud-telnet

Apache-2.0

11KB
136 lines

crates.io  Rust license  documentation

wasmCloud Telnet Server Actor Interface

This crate provides an abstraction over the wasmcloud:telnet contract. This allows actors to be notified when a new telnet session has started and when text has been received on a given session. Actors can also emit text to a specific session, which ultimately correlates to an individual connected socket client.

Example:

extern crate wasmcloud_actor_telnet as telnet;
extern crate wasmcloud_actor_core as actorcore;
use wapc_guest::HandlerResult;

#[no_mangle]
pub fn wapc_init() {
    telnet::Handlers::register_session_started(session_started);
    telnet::Handlers::register_receive_text(receive_text);
    actorcore::Handlers::register_health_request(health);
}

fn session_started(session: String) -> HandlerResult<bool> {
   let _ = telnet::default().send_text(session, "Welcome to the Interwebs!\n".to_string());
   Ok(true)
}
fn receive_text(session: String, text: String) -> HandlerResult<bool> {
   let _ = telnet::default().send_text(session, format!("Echo: {}\n", text));
   Ok(true)
}

fn health(_h: core::HealthCheckRequest) -> HandlerResult<core::HealthCheckResponse> {
    Ok(core::HealthCheckResponse::healthy())
}

Dependencies

~0.7–1.4MB
~30K SLoC