CC Web Socket

CC Web Socket provides a robust and flexible WebSocket client for Flutter applications. This package allows you to easily manage and customize WebSocket connections.

For more detailed information:


  • Easy Initialization: Quickly establish WebSocket connections with simple configuration options.
  • Timeout and Ping Settings: Customize connection timeout and ping intervals.
  • Automatic Reconnection: Automatically reconnect when the connection is lost.
  • Detailed Logging: Options for logging connection status, requests, and responses.
  • Modular Structure: Extend functionality with plugins and modules.


Add this package to your project by including the following line in your pubspec.yaml file:

  cc_web_socket: ^1.0.0



To initialize CCWebSocket, use the following code:

  socketOptions: CCSocketOptions(
    uri: Uri(
      scheme: "wss",
      host: "",
      port: 443,
      path: ".ws",
    connectTimeout: const Duration(seconds: 5),
    pingInterval: const Duration(seconds: 120),
    requestTypeName: "request_type",
    autoConnect: true,
  loggingOptions: CCSocketLogging(
    logEnabled: true,
    onConnection: (prompt) {},
    onReconnection: (prompt) {},
    onClosed: (prompt) {},
    onRequest: (prompt) {},
    onResponse: (prompt) {},
    onError: (prompt) {},
  modules: [

NOTE The requestTypeName parameter is an identifier in the JSON content that matches the correct module for the returned data.


To initiate the WebSocket connection, use the following code:


Module Usage

To send a request through a module:

  body: {
    "request_type": "Unknown",

Example Module

You can create your own module by defining a class like this:

class Example extends RequestModule {
  void request({required Map<String, dynamic> body}) {
    super.request(body: body);

  void response(dynamic response) {}

or to handle only the response:

class Example extends RequestModule {
  void response(dynamic response) {}


If you want to contribute, please submit a pull request or open an issue. We value all kinds of feedback.


This project is licensed under the MIT License. For more information, see the LICENSE file.