Polo: WebSocket Library
A WebSocket Library written in Pure Dart. Easy API for writing WebSocket based Apps or Games, also Support for Flutter and Web.
📦 Packages
Name |
Link |
Language / Runtime |
polo_server |
|
Dart |
polo_client |
|
Dart |
polo_client_ts |
|
Deno (TypeScript) |
✨ Features
- Multi-Platform
Android
, IOS
, Windows
, Linux
, macOS
, Web
.
- Typed Events
- Refer
PoloType
and PoloTypeAdapter
.
- Library Officially Available in Multiple Programming Languages
- Easy to Use API
📖 Getting Started
Basic Chat App
// Polo Server
PoloServer server = await Polo.createServer();
server.onClientConnect((client) {
print("Client(${client.id}) Connected!");
client.onEvent<String>('message',
(message) => server.broadcastFrom<String>(client, 'message', message));
});
server.onClientDisconnect((client) {
print("Client(${client.id}) Disconnected!");
});
// Polo Client
PoloClient client = await Polo.connect("ws://127.0.0.1:3000/");
client.onConnect(() {
print("Client Connected to Server");
});
client.onDisconnect(() {
print("Client Disconnected from Server");
});
client.onEvent<String>('message', (message) {
print("$message");
});
client.listen();
// Polo Client
const client: PoloClient = await Polo.connect("ws://127.0.0.1:3000/");
client.onConnect(() => {
console.log("Client Connected to Server");
});
client.onDisconnect(() => {
console.log("Client Disconnected from Server");
});
client.onEvent<string>("message", (message) => {
console.log(`${message}`);
});
client.listen();
💪 Contributions
Libraries
-
polo_server
- Support for doing something awesome.