oichat_sdk 0.1.1 copy "oichat_sdk: ^0.1.1" to clipboard
oichat_sdk: ^0.1.1 copied to clipboard

OiChat Flutter SDK - Real-time chat client with REST API and Centrifugo WebSocket

OiChat

pub.dev version pub points Sample Docs License

oichat_sdk #

OiChat Flutter SDK for real-time chat integration — REST API client + Centrifugo WebSocket messaging.

한국어 | English

Features #

  • Room management (create, list, join, leave)
  • Real-time messaging via Centrifugo WebSocket
  • Presence tracking (online/offline)
  • File upload support
  • Push notification token management
  • Multi-tenant support with project isolation
  • Server Mode + Client Mode

Getting Started #

Installation #

dependencies:
  oichat_sdk: ^0.1.0
flutter pub get

Server Mode #

Your backend issues JWT tokens and passes them to the client.

import 'package:oichat_sdk/oichat_sdk.dart';

final client = OiChatClient(
  baseUrl: 'https://api.oichatapi.com',
  wsUrl: 'wss://ws.oichatapi.com/connection/websocket',
  projectId: 'proj_xxxxxxxxxxxx',
  secretKey: 'sk_xxxxxxxxxxxx',
  userId: 'user-123',
);

// Connect with JWT token from your backend
await client.realtime.connect(token: jwtFromServer);

Client Mode #

SDK handles token issuance and auto-refresh internally.

import 'package:oichat_sdk/oichat_sdk.dart';

final client = await OiChatClient.initClient(
  baseUrl: 'https://api.oichatapi.com',
  wsUrl: 'wss://ws.oichatapi.com/connection/websocket',
  projectId: 'proj_xxxxxxxxxxxx',
  publicKey: 'pk_xxxxxxxxxxxx',
  userId: 'user-123',
  userName: 'John Doe',
);

Core APIs #

Rooms #

// List rooms
final result = await client.rooms.list(limit: 20);

// Create room
final room = await client.rooms.create(
  type: 'group',
  name: 'Support Chat',
  participantIds: ['user-1', 'user-2'],
);

Messages #

// Subscribe to a room
final sub = await client.realtime.subscribeRoom('room-id');

// Listen for new messages
sub.onMessage.listen((message) {
  print(message.content);
});

// Send a message
await client.messages.send(
  roomId: 'room-id',
  content: 'Hello!',
  contentType: ContentType.text,
);

Real-time Events #

// Typing indicator
sub.onTyping.listen((event) {
  print('${event.userId} is typing...');
});

// Read receipts
sub.onRead.listen((event) {
  print('${event.userId} read messages');
});

// Connection state
client.realtime.onConnectionStateChange.listen((state) {
  print('Connection: $state');
});

Push Notifications #

await client.push.registerToken(
  token: fcmToken,
  deviceType: DeviceType.android,
);

Cleanup #

client.dispose();

한국어 #

모바일 앱에 채팅을 붙이는 가장 쉬운 방법 — REST API 클라이언트 + Centrifugo WebSocket 실시간 통신.

설치 #

dependencies:
  oichat_sdk: ^0.1.0
flutter pub get

빠른 시작 #

서버 모드

백엔드에서 JWT 토큰을 발급하여 클라이언트에 전달하는 방식입니다.

import 'package:oichat_sdk/oichat_sdk.dart';

final client = OiChatClient(
  baseUrl: 'https://api.oichatapi.com',
  wsUrl: 'wss://ws.oichatapi.com/connection/websocket',
  projectId: 'proj_xxxxxxxxxxxx',
  secretKey: 'sk_xxxxxxxxxxxx',
  userId: 'user-123',
);

// 백엔드에서 받은 JWT 토큰으로 연결
await client.realtime.connect(token: jwtFromServer);

클라이언트 모드

SDK가 자동으로 토큰 발급/갱신 + 연결을 처리합니다.

final client = await OiChatClient.initClient(
  baseUrl: 'https://api.oichatapi.com',
  wsUrl: 'wss://ws.oichatapi.com/connection/websocket',
  projectId: 'proj_xxxxxxxxxxxx',
  publicKey: 'pk_xxxxxxxxxxxx',
  userId: 'user-123',
  userName: '홍길동',
);

주요 기능 #

기능 설명
채팅방 관리 생성, 목록, 참여, 나가기
실시간 메시징 Centrifugo WebSocket 기반
프레전스 온라인/오프라인 상태 추적
파일 업로드 이미지, 파일 전송 지원
푸시 알림 FCM 토큰 등록
멀티 테넌트 프로젝트 단위 데이터 격리

관련 링크 #

License #

MIT

0
likes
125
points
23
downloads

Documentation

API reference

Publisher

verified publisheroichatapi.com

Weekly Downloads

OiChat Flutter SDK - Real-time chat client with REST API and Centrifugo WebSocket

Homepage
Repository (GitHub)

License

MIT (license)

Dependencies

centrifuge, http, json_annotation

More

Packages that depend on oichat_sdk