#if !BESTHTTP_DISABLE_SIGNALR_CORE
using System;
using System.Collections.Generic;
using BestHTTP.PlatformSupport.Memory;
namespace BestHTTP.SignalRCore
{
public enum TransportTypes
{
#if !BESTHTTP_DISABLE_WEBSOCKET
WebSocket,
#endif
LongPolling
}
public enum TransferModes
{
Binary,
Text
}
public enum TransportStates
{
Initial,
Connecting,
Connected,
Closing,
Failed,
Closed
}
///
/// Possible states of a HubConnection
///
public enum ConnectionStates
{
Initial,
Authenticating,
Negotiating,
Redirected,
Reconnecting,
Connected,
CloseInitiated,
Closed
}
///
/// States that a transport can goes trough as seen from 'outside'.
///
public enum TransportEvents
{
///
/// Transport is selected to try to connect to the server
///
SelectedToConnect,
///
/// Transport failed to connect to the server. This event can occur after SelectedToConnect, when already connected and an error occurs it will be a ClosedWithError one.
///
FailedToConnect,
///
/// The transport successfully connected to the server.
///
Connected,
///
/// Transport gracefully terminated.
///
Closed,
///
/// Unexpected error occured and the transport can't recover from it.
///
ClosedWithError
}
public interface ITransport
{
TransferModes TransferMode { get; }
TransportTypes TransportType { get; }
TransportStates State { get; }
string ErrorReason { get; }
event Action OnStateChanged;
void StartConnect();
void StartClose();
void Send(BufferSegment bufferSegment);
}
public interface IEncoder
{
BufferSegment Encode(T value);
T DecodeAs(BufferSegment buffer);
object ConvertTo(Type toType, object obj);
}
public sealed class StreamItemContainer
{
public readonly long id;
public List Items { get; private set; }
public T LastAdded { get; private set; }
public bool IsCanceled;
public StreamItemContainer(long _id)
{
this.id = _id;
this.Items = new List();
}
public void AddItem(T item)
{
if (this.Items == null)
this.Items = new List();
this.Items.Add(item);
this.LastAdded = item;
}
}
struct CallbackDescriptor
{
public readonly Type[] ParamTypes;
public readonly Action