clarify how bidirectional communication should work
Los mantenedores suelen responder en 5 días
Nadie ha tomado este issue todavía.
- #247 de @ting-hong-shieh — cerrado sin fusionar
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- documentation
Línea de trabajo
Comienza con el comportamiento de comunicación bidireccional mostrado en este issue mediante newWebSocketRpcSession, RpcTarget, las funciones de callback y los ejemplos de temporizadores. Revisa el repositorio de ejemplo enlazado para entender el flujo mostrado y documenta los callbacks de estilo notificación y los problemas de async y los temporizadores con ejemplos ejecutables. La tarea estará terminada cuando los recién llegados puedan entender cómo usar la comunicación bidireccional y qué comportamiento temporal esperar.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Heya, neat library. Almost what I was asking for just a day ago 😆
I'm having a hard time understanding how to achieve bidirectional communication. It's almost worded like you can just push data back to the client, but I think that's not the right kind of thinking. So I dug deeper I ended up using the functionality that allows you to pass functions by reference- it seems like this is kind of what's intended?
Where it gets really confusing when you add things like timers into the equation. Without marking the method as async and awaiting a promise directly, it doesn't behave as you'd expect (from a "nieve" point of view, that is.)
I have an example repository you can use to explore this in more depth
Example client:
using wsApi = newWebSocketRpcSession<MyWs>("ws://localhost:8000");
const d = (sm: string) => console.log("got something: " + sm)
const wsResult = await wsApi.test(d);
console.log(wsResult);
Example websocket "client":
class WsServer extends RpcTarget {
async test(fn: (data: string) => void) {
fn("testing");
setTimeout(1000, () => {
fn("hello from timeout");
});
return true;
}
}
It'll call the first function, then return true. That makes a lot of sense! I would expect this to be a "gotcha" here and not a bug of the protocol (how would you know timers are involved?)
Now replace the setTimeout with an import from node:timers/promises:
class WsServer extends RpcTarget {
async test(fn: (data: string) => void) {
fn("testing");
const msg = await setTimeout(1000, "da");
fn(msg);
return true;
}
}
We'll get what we want:
got something: testing
got something: da
true
The ask here is if we can get some examples of bidirectional communication and the "gotchas" those comes with. I can see how functions can be used to achieve the "notification" style API for a client and this is something I'm looking to explore :)
- Lenguaje dominante
- TypeScript
- Estrellas
- 4k
- Forks
- 150
- Merge medio
- 3 d 12 h
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de cloudflare/capnweb
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
cloudflare/capnweb#269 · 2 comentarios ·
Los mantenedores suelen responder en 5 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
cloudflare/capnweb#260 ·
Los mantenedores suelen responder en 5 días
-
onRpcBroken should return a Disposable so registrations can be undoneQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
cloudflare/capnweb#234 · 1 comentario ·
Los mantenedores suelen responder en 5 días
-
support `Map` serialization typePosiblemente ocupada @srikrsna la tomó hace 82 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
cloudflare/capnweb#230 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
cloudflare/capnweb#228 ·
Los mantenedores suelen responder en 5 días
Todos los issues de cloudflare/capnweb
Issues similares
-
New icon: `filter-clear`Abiertocalcite-ui-icons enhancement impact - p3 - not time sensitive needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Esri/calcite-design-system#15467 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
diegosouzapw/OmniRoute#18390 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
guilhermerodz/input-otp#157 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
davidjerleke/embla-carousel#1414 ·
Los mantenedores suelen responder en 4 días