Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a UDP networking service #5

Closed
Levi-Lesches opened this issue Jun 10, 2022 · 2 comments · Fixed by #25
Closed

Implement a UDP networking service #5

Levi-Lesches opened this issue Jun 10, 2022 · 2 comments · Fixed by #25
Assignees
Labels
area: networking Involves network communications type: enhancement New feature or request

Comments

@Levi-Lesches
Copy link
Member

Levi-Lesches commented Jun 10, 2022

We need a RoverNetwork service that can:

  • establish a connection with the rover (it's UDP, so probably just a few pings)
  • send messages to the rover as serialized Protobuf messages
  • receive Protobuf messages from the rover

Loosely going from the above, we'd probably need the following:

class RoverNetwork extends Service {
  Future<void> init();  // send pings until receive response
  Future<void> send(RoverMessage message);  // sends a message to the rover
  Stream<RoverMessage> incomingMessages;  // receives incoming messages from the rover
}

We'd use a stream for incoming messages since dart:io uses it for its RawDatagramSocket UDP implementation. It will also help the front end, which has built-in support for updating widget values based on data from a Stream object.

@superdan-t
Copy link
Collaborator

This is blocked by the draft issue Revise network message-passing protocol for inter-language implementation.

It might be worth putting in a separate repo with the other network stuff but we can decide that when the task is unblocked.

(Also bumped from med to large since I think this is one of the bigger tasks)

@Levi-Lesches Levi-Lesches added the area: networking Involves network communications label Jun 15, 2022
@Levi-Lesches Levi-Lesches added the blocked This PR needs is waiting for one or more issues to be closed. label Jun 22, 2022
@Levi-Lesches Levi-Lesches added type: enhancement New feature or request and removed blocked This PR needs is waiting for one or more issues to be closed. labels Jul 21, 2022
@Levi-Lesches Levi-Lesches changed the title Implement a networking service Implement a UDP networking service Sep 30, 2022
@Levi-Lesches
Copy link
Member Author

We've decided to go with a Stream-like API, but without directly exposing streams. We're using:

class MessageSender extends Service {
  /// Wraps [message] in a [WrapperMessage] and sends over UDP.
  Future<void> send(Message message);   
}

class MessageReceiver extends Service {
  /// Runs [handler] with the message decoded by [decoder] whenever a message of type [name] appears.
  void registerHandler<T extends Message>({
    required String name, 
    required MessageDecoder<T> decoder, 
    required Handler<T> handler
  });
}

@Levi-Lesches Levi-Lesches linked a pull request Oct 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: networking Involves network communications type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants