Creating a new explicit message-passing mode
- Lingua principale
- Haskell
- Stelle
- 1.3k
- Fork
- 201
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
A new collaborationOf mode could use the message relay server introduced with the gameOf mode to relay user-defined messages instead of Events. A new data type Message should be provided by CodeWorld to the user, like this:
```
data Message = TextMsg Data.Text.Text | IntMsg [Int] | DoubleMsg [Double]
```
Providing both a text payload and a list of numbers payload would reduce the need of having heavy parsing in the client code, while still avoiding having to implement serialization of arbitrary data.
The idea is to have clients being able to send and receive data as simply as possible, so that it does not
require much extra effort from students. My initial use case would be visualizing parallel algorithms to do matrix computations, so having the protocol handle list of numbers without extra work on the client code would be really useful.
The collaborationOf function should be something like this:
```
collaborationOf initial step event picture numParticipants send receive
```
The first part (initial,step,event,picture) would be just like interactionOf. Keyboard and Mouse events would be local to each client, and they would be handled by the local event handler.
The communication between nodes would be handled by the new functions send and receive:
```
send: State -> Maybe Message
receive: LocalId -> RemoteId -> Message -> State
```
The function send should be run by CodeWorld periodically after each update. The function receive would be run when a message is received, similar to how the event handler is run for local events.
The users would be responsible for writing the code for send and receive, just like the others (initial,update,handle,view). If the output of send is Nothing, no message is generated. Otherwise, the
message is sent to the relay server, which broadcasts it to all the nodes. Each node would receive the message along with their own node identifier and the identifier of the original sender of the message.
The function receive would use that information to update the local state as needed.
I think this mode does not require much extra work over the current gameOf, but it would make it more flexible, as it separates events that should be handled locally from those that are sent over the network in a way that is completely controlled by the client code.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia leggendo le implementazioni esistenti di gameOf e interactionOf e il server di relay dei messaggi descritto nell’issue. Determina come un tipo Message, collaborationOf, send e receive si inserirebbero nell’attuale flusso degli eventi e degli aggiornamenti dello stato. Il lavoro sarà completo quando saranno disponibili un design concordato e una modalità di passaggio dei messaggi implementata e testata, che supporti gli eventi locali e i messaggi di broadcast.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- haskell
- Ambito
- distributed-systems
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100