riptide 0.2.0 copy "riptide: ^0.2.0" to clipboard
riptide: ^0.2.0 copied to clipboard

Dart port of the Riptide library from Tom Weiland. This port provides functionality for establishing connections with clients and servers using the Riptide protocol.

example/main.dart

import 'dart:io';

import 'package:riptide/riptide.dart';

enum ClientToServerId { serverTest }

enum ServerToClientId { clientTest }

void createClient() {
  Client client = Client();
  client.connect(InternetAddress('127.0.0.1'), 7777);

  client.registerMessageHandler(ServerToClientId.clientTest.index,
      (Message message) {
    print(message);
  });

  client.clientConnected.subscribe((args) {
    // send a test message to the server on connection
    Message message = Message.createFromInt(
        MessageSendMode.reliable, ClientToServerId.serverTest.index);
    message.addString('Hello Server!');
    client.send(message);
  });
}

void createServer() {
  Server server = Server();
  server.start(7777, 10);

  server.registerMessageHandler(ClientToServerId.serverTest.index,
      (fromClientID, message) {
    print("received message from client $fromClientID");
  });

  server.clientConnected.subscribe((args) {
    // send a test message to each connecting client
    Message message = Message.createFromInt(
        MessageSendMode.reliable, ServerToClientId.clientTest.index);
    message.addString('Hello Client!');
    server.send(message, args!.client.id);
  });
}
copied to clipboard
1
likes
130
points
60
downloads

Publisher

verified publisherjaykaycooperations.com

Weekly Downloads

2024.09.16 - 2025.03.31

Dart port of the Riptide library from Tom Weiland. This port provides functionality for establishing connections with clients and servers using the Riptide protocol.

Repository (GitHub)

Topics

#network

Documentation

API reference

License

MIT (license)

Dependencies

collection, intl

More

Packages that depend on riptide