/* * MIT License * * Copyright (c) 2018 Clark Yang * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ using System; using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; namespace Loxodon.Framework.Net.Connection { public interface IConnector : IDisposable where TRequest : IRequest where TResponse : IResponse where TNotification : INotification { /// /// Whether a connection has been established. /// bool Connected { get; } /// /// Whether to automatically reconnect to the server when the connection is abnormal, /// it only tries to reconnect once, if the connection to the server fails, it will not try again /// bool AutoReconnect { get; set; } /// /// Connects the Client to the specified port on the specified host. /// Supports IPV6 and IPV4, it is recommended to use domain names instead of IP addresses /// /// /// /// /// /// /// Task Connect(string hostname, int port, int timeoutMilliseconds); /// /// Connects the Client to the specified port on the specified host. /// Supports IPV6 and IPV4, it is recommended to use domain names instead of IP addresses /// /// /// /// /// /// Task Connect(string hostname, int port, int timeoutMilliseconds, CancellationToken cancellationToken); /// /// Reconnect to the server /// /// /// /// Task Reconnect(); /// /// Reconnect to the server /// /// /// Task Reconnect(CancellationToken cancellationToken); /// /// Forces a connection to disconnect. /// /// Task Disconnect(); /// /// Shutdown service /// /// Task Shutdown(); /// /// Subscribe to events /// /// ISubscription Events(); /// /// Subscribe to notification messages /// /// ISubscription Received(); /// /// Subscribe to notification messages /// /// /// ISubscription Received(Predicate filter); /// /// Send a request message /// /// /// /// Task Send(TRequest request); /// /// Send a request message /// /// /// /// /// Task Send(TRequest request, int timeoutMilliseconds); /// /// Send a request message /// /// /// /// /// Task Send(TRequest request, CancellationToken cancellationToken); /// /// Send a request message /// /// /// /// /// /// Task Send(TRequest request, int timeoutMilliseconds, CancellationToken cancellationToken); /// /// Send a notification message /// /// /// Task Send(TNotification notification); } }