Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A comprehensive WebSocket library for .NET providing both client and server implementations with support for multiple application types.

License

NotificationsYou must be signed in to change notification settings

Maanfee/Maanfee-WebSocket

Repository files navigation

Maanfee

A comprehensive WebSocket library for .NET providing both client and server implementations with support for multiple application types.

✨ Features

  • Full-duplex communication - Real-time bidirectional messaging
  • Automatic reconnection - Configurable retry policies
  • User management - Track and manage connected users
  • State management - Comprehensive state tracking for client/server
  • Cross-platform - Works with ASP.NET Core, Blazor, Console apps
  • Thread-safe - Safe for concurrent operations
  • Memory efficient - UsesArrayPool for buffer management
  • Event-driven - Comprehensive event system
  • Dependency Injection - Seamless integration with ASP.NET Core

📦 Packages

Maanfee.WebSocket

A high-performance WebSocket library for .NET including:

  • MaanfeeWebSocketServer - Full-featured WebSocket server with user management
  • MaanfeeWebSocketClient - WebSocket client with auto-reconnection capability
  • MaanfeeWebSocketOption - Advanced configuration for connection settings
  • MaanfeeWebSocketUser - Management of connected user information
  • WebSocketServerState &WebSocketClientState - Comprehensive state management
  • Event arguments and helper classes

Maanfee.Examples

Example implementations demonstrating usage in different application types.

🛠️ API Reference

WebSocketServer Methods

MethodDescription
Start()Start the server
StopAsync()Gracefully stop the server
HandleWebSocketConnectionAsync(WebSocket)Handle new WebSocket connections
SendToAllAsync(string)Send message to all connected clients
SendToClientAsync(string , string)Send message to specific client
GetConnectedUsersCount()Get count of connected users
GetConnectedUserIds()Get list of connected user IDs
GetUserById(string)Get user by ID
GetAllUsers()Get all users
Dispose()Clean up resources
EventsDescription
ClientConnectedWhen new client connects
ClientDisconnectedWhen client disconnects
ServerStoppedWhen server stops
MessageReceivedWhen message received from client
StateChangedWhen server state changes

WebSocketClient Methods

MethodDescription
ConnectAsync()Connect to WebSocket server
SendMessageAsync(string)Send message to server
DisconnectAsync()Disconnect from server
Dispose()Clean up resources
EventsDescription
MessageReceivedWhen message received from server
ConnectionClosedWhen connection closes
ErrorOccurredWhen error occurs
ConnectedWhen connection established successfully
StateChangedWhen client state changes

🚀 Quick Start

📦 Installation

Package Manager

<PackageReferenceInclude="Maanfee.WebSocket"Version="*" />

Solution Configuration Guide

Steps to Configure Multiple Startup Projects

  1. Open the Solution

    • Right-click on the solution name in the Solution Explorer
  2. Access Solution Properties

    • Go toProperties
  3. Configure Startup Projects

    • Navigate toMultiple startup projects

Available Project Profiles

Web API Server Profile

  • Server: Web API Server
  • Clients:
    • Blazor
    • Web API
    • Console

Console Server Profile

  • Server: Console Server
  • Clients:
    • Blazor
    • Web API
    • Console

Blazor Server Profile (Recommended)

  • Server: Blazor Server
  • Clients:
    • Blazor
    • Web API
    • Console

Configuration Options

Each profile allows you to set different combinations of server and client applications for testing and development purposes.

About

A comprehensive WebSocket library for .NET providing both client and server implementations with support for multiple application types.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2026 Movatter.jp