Skip to content

joshjohanning/Wolfringo-github-packages

 
 

Repository files navigation

Wolfringo

Nuget GitHub top language GitHub GitHub Workflow Status GitHub issues

This is a .NET library for WOLF (previously Palringo).

This library is designed with extensibility through Dependency Injection in mind, and is compatible with ASP.NET Core and other .NET Core Hosting scenarios through Wolfringo.Hosting package.

Library works with strongly-typed messages and responses, that are serialized when sending and deserialized when receiving. Message listeners can be invoked by message type, giving full benefit of strong typing. Additionally, Wolfringo.Utilities package provides a Sender extensions class, which abstracts common sending tasks. Utilities package is included by default with Wolfringo meta-package.

Wolfringo provides a built in Commands System. Commands System uses attributes to mark commands, which greatly reduces amount of boilerplace code needed.
The Commands System follows the design principles of entire Wolfringo library, and therefore is easily extensible and easily customizable thanks to Dependency Injection.

Documentation

A full Documentation is now available - it includes Tutorials and Guides, as well as full API Reference.

Download

Most recent versions of this package are downloadable via nuget.org!

  1. Install package in your project
    Install-Package Wolfringo
    
  2. (.NET Core Host/ASP.NET Core only) Install Wolfringo.Hosting package
    Install-Package Wolfringo.Hosting
    

Older versions

Older versions are available through GitHub Packages. See Installation guide in Documentation for steps to install version before v0.4.0.

Requirements

The library targets .NET Standard 2.0, and therefore works with .NET Core 2.0+, .NET Framework 4.6.1+ and .NET 5+.

See Introduction in documentation for more details.

Extending the client

Serializer providers

Client uses power of Dependency Injection to allow customizability. The client accepts optional Message and Response Serializer providers which are used for serializing and deserializing the message and response objects. You can inject own instance of the map to change mapping, or even add new types through their options if it's required.

You can see MessageSerializerProvider, ResponseSerializerProvider, DefaultMessageSerializer and DefaultResponseSerializer for examples of default base implementations.

To check the default mappings, see MessageSerializerProviderOptions and ResponseSerializerProviderOptions.

Overriding client methods

Client automatically caches the entities based on message/response type. If you add a new type that needs to support this, you must create a new client class inheriting from WolfClient. You can override OnMessageSentInternalAsync method to change behaviour for sent messages and received responses, and OnMessageReceivedInternalAsync method to change behaviour for received events and messages.

Note: it's recommended to still call base method after own implementation to prevent accidentally breaking default behaviour. Overriding these methods should be handled with caution.

Determining response type for sent message

WolfClient needs to know how to deserialize message's response, and to determine the type, it uses an IResponseTypeResolver to select the type that will be used with response serializer mappings. This interface can be passed into the client constructor. If null or none is passed in, DefaultResponseTypeResolver will be used automatically.

DefaultResponseTypeResolver respects ResponseType attribute on the message type, and will ignore the generic type passed in with SendAsync method. If the attribute is missing, default client implementation will instruct the type resolver to use provided generic type. Client will attempt to cast the response to the provided generic type regardless of the actual response type, and might throw an exception if the cast is impossible.

Further development

Known bugs and missing features

  • Avatar setting is not supported, due to Wolf protocol not supporting it yet.
  • Spam filter settings is not supported.

Contributing

To ask questions or give ideas for Wolfringo, start a new Discussion.

In case you want to report a bug or request a new feature, open a new Issue.

If you want to contribute a patch or update, fork repository, implement the change, and open a pull request.

License

Copyright (c) 2020 TehGM

Licensed under MIT License.

About

A .NET Library for WOLF (previously Palringo)

Resources

License

Stars

Watchers

Forks

Languages

  • C# 100.0%